I am about to use Caliburn.Micro for a new XAML Store app (not sure what to call it nowadays - does not appear to be called a "Windows Store app" any longer).

The documentation (see Simple Navigation section) advocates using UserControls for "Views" which can be contained in a "Shell".

As an experienced WPF developer I am hesitant to do so because:

  1. A UserControl in XAML is for making a reusable control, e.g. a date time picker. It is not designed to be a whole view you only have once in your application (use a Page or Window for that).
  2. Splitting a View up into sub-views only makes your life harder when you want to communicate between what would have all had the same ViewModel.
  3. All the extra code and files!

My suspicion is this UserControl abuse comes from developers used to UserControls in ASP where they can define a section of View.

Should XAML UserControl's be used like this?

  • 5
    What's the alternative? – MetaFight Feb 3 '15 at 9:22
  • @MetaFight don't split your Views into sub views that are not not naturally sub views, i.e. keep it all in the Page. – markmnl Feb 3 '15 at 13:52
  • I don't see how splitting a view makes it more difficult to communicate with a single view model, but that's not what I was asking about. What I was asking is: If a you're suggesting Views shouldn't be UserControls then what else could they be? Would they derive from another class? – MetaFight Feb 3 '15 at 14:00
  • 2
    I've always been in the habit of making my Views UserControlss so they're not bound to a specific presentation (window, page, whatever). – MetaFight Feb 3 '15 at 14:07
  • 1
    You have made a mindset that a UserControl can only be reusable which need not be the case always. It serves a good option of separating your view code as well. And that's the point @MetaFight is making here. It's much better to split your view (Yes! using UserControl) rather than having view.xaml containing 100s of lines. – Nikhil Vartak Apr 18 '16 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.