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
Post a Comment