c# - PropertyChanged event not Handled properly -


i'm trying property changed event handler working, , i've checked dubugger onpropertychanged method being called, it's not invoking method expecting to.

public class mainviewmodel : observableobject {     public mainviewmodel()     {         _characterselection = new characterselectionviewmodel();         _characterselection.propertychanged += new propertychangedeventhandler(characterselection_propertychanged);     }      private void characterselection_propertychanged(object sender, propertychangedeventargs e)     {         if (e.propertyname.equals("character"))         {             _character = _characterselection.character;             _currentview = _newcharacter;             onpropertychanged("currentview");         }     } }  [serializable] public class observableobject : inotifypropertychanged {     public event propertychangedeventhandler propertychanged;      // create onpropertychanged method raise event      protected void onpropertychanged(string property)     {         propertychangedeventhandler handler = propertychanged;         if (handler != null)         {             handler(this, new propertychangedeventargs(property));         }     } }  public class characterselectionviewmodel : observableobject {     private void newcharacter()     {         charactersaver.savecharacter(charactername, _character);         onpropertychanged("character");     } } 

i've stepped through debugger, constructor mainviewmodel() gets called, , adds propertychangedeventhandler. @ point, _characterselection's propertychanged event has value: (from locals tab in debugger)

{method = {void characterselection_propertychanged(system.object, system.componentmodel.propertychangedeventargs)}} 

once newcharacter method in characterselectionviewmodel gets called, calls onpropertychanged. @ point, _characterselection's propertychanged event has value:

{method = {void onpropertychanged(system.object, system.componentmodel.propertychangedeventargs)}} 

the onpropertychanged event gets handler(this, new propertychangedeventargs(property)); line, characterselection_propertychanged() never invoked. no errors thrown.

what did miss? help.

you may have binding set such having separate instance of characterselectionviewmodel instead of instance on mainviewmodel. check bindings ensure you're bound mainviewmodel, , you're utilizing instance of characterselectionviewmodel icommand binding ensure event you're subscribing (on correct instance) raised.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -