.net - "Simple MVVM Toolkit" child Model classes in C# WPF -


i'm using "simple mvvm toolkit" (mvvm noob here) develop c# wpf app.

i have model class called a:

public class : modelbase<a> {     //properties, constructors, methods.. } 

..and model class called b inherits a exposes property a doesn't have:

public class b : {     private string additionalproperty;     public string additionalproperty     {         { return additionalproperty; }         set         {              additionalproperty = value;              //notifypropertychanged(m => m.additionalproperty); <-- problem here         }     } } 

problem comes commented line above: lambda in notifypropertychanged won't work because m.additionalproperty doesn't exist, since m of type a, not b. happens in case? should note notifypropertychanged comes toolkit , not custom implementation.

edit: here intellisense description notifypropertychanged in b:

void modelbasecore<a>.notifypropertychanged<tresult>(system.linq.expressions.expression<func<a,tresult>> property) 

allows specify lambda notify property changed

the problem in how implemented modelbase. didn't feel subclassing model subclasses modelbase, i'm not sure why they'd think that.

in case, issue you're telling modelbase type use resolution when specify generic: modelbase<a>. around this, have rather convoluted generic play looks pretty goofy:

public class a<t> : modelbase<t> t : a<t> {     //properties, constructors, methods.. }  public class b : a<b> {     private string additionalproperty;     public string additionalproperty     {         { return additionalproperty; }         set         {              additionalproperty = value;              notifypropertychanged(m => m.additionalproperty);         }     } } 

note a inherits modelbase<t> not modelbase<a>, , constrain t a<t>. have b inherit a , specify generic b (which implements a<t>).

this rather convoluted, , i'm not sure why did way - possibly because there's cross-platform things require them this. if don't need cross-platform work, or possibly didn't reason, instead recommend use mvvm light mvvm needs. has different implementation notifypropertychanged doesn't depend on specifying own type, , reduces need over-use of generics.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -