c# - Can I get a reference to the object binded in the XAML from my UserControl class? -


i have xaml paired cs class inherits usercontrol class. access in class object being binded (binding source) in xaml, , make changes in ui depending on properties of object when event triggered. there way manage this?

thanks in advance.

i think you're looking datacontext. usercontrol's cs class:

var myobject = (mytype)this.datacontext; myobject.propertychanged += myhandler; 

note datacontext won't set when you're in constructor. should able in loaded event or later.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -