user - Right way of creating own UserControls in WPF (Csharp) -


i have moral question :) creating own controls (deriving usercontrol) in wpf. there 2 ways:

  1. i using 1 xaml , 1 cs file , have there stuff
  2. i loyal mvvm , create 1 xaml , cs file user control plus 1 cs file view model , using mvvm technique. have use control this: in xaml:

    <contentcontrol content={binding mycontrol.... 

    in code:

    mycontrol = new mycontrolviewmodel() 

till used second approach reading wise articles , seems many ppl uses first. should mix view , logic while creating controls? of course keep mvvm in other parts of app (i try keep logic stuff in view model). couse afraid cs file long.

my opinion that, rule of thumb, requires explicit vm not control, it's kind of component. controls should simple , have no advanced business logic.

well, if see code needs vm, can have written component, there's no problem in having separate vm class it.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -