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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -