mardi 3 février 2015

Should UserControl's be Views in an XAML MVVM application (WPF or Store app)?


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?





Aucun commentaire:

Enregistrer un commentaire