c# - Use "Binding" class to listen property path changes for code-behind operations -
binding class provides listening property paths
example:
<textblock text="{binding a.b.c.d.e}" />
reflects change in property chain
i want utilize mechanism in code behind.
what want do:
var binding = new binding{ source = viewmodel, path = new propertypath("a.b.c.d.e") }; // not available binding.resultchanged += onbindingresultchanged;
but "binding" doesn't provide events
i think u should use onpropertychanged event. implement this
public class yourclass : window, inotifypropertychanged public string a.b.c.d.e {get ; set ;} public event propertychangedeventhandler propertychanged; protected void onpropertychanged(string name) { propertychangedeventhandler handler = propertychanged; if (handler != null) { handler(this, new propertychangedeventargs(name)); } }
after in xaml can raise event when property changed.
<textblock text="{binding a.b.c.d.e}" textchanged="yourmethodename"/>
when methode called can change value of property in code behind.
public void yourmethodename (sender e, routeeventargs) { //dostuff property onpropertychanged ("a.b.c.d.e) }
this way can change value property in code behind , user input.
Comments
Post a Comment