DataBinding with Converter not updating when Context changes.
<usercontrol.resources> <local:ymmconverter x:key="yearmakemodelconverter"/> </usercontrol.resources>
<textblock text="{binding converter={staticresource yearmakemodelconverter}, mode=oneway}" />
i assign datacontext of textblock vehicleinfo class after initializecomponent(). when usercontrol loads, looks great. function of usercontrol allows user change details of vehicle. have button goes , changes year, make, , model properties of vehicleinfo. using debugger, notice changes applied, textblock not.
is there better way combine properties single bound control? understand change vehicleinfo expose new property combined these properties, however, seems big headache create custom classes every time want display combined properties.
ideas?
the reasoning because need able retrieve multiple properties "vehicleinfo". if set property converter has access value of single property.
in real world example, vehicleinfo is generated through wcf, modifying was directly out of question. however, didn't remember when posted class generated wcf partial class. so, created partial class under same namespace , name, added property yearmakemodel getter, , subscribed propertychange event handler in constructor. in the event handler check if property changed year, make, or model. if was, call propertchanged(this, new propertychangedeventargs("yearmakemodel")). had set xaml binding property "yearmakemodel" , voila, changes data!
this works great me because it's reusable in entire sl application (automatically), it's overhead light, , accomplishes goal of combining fields via binding.
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment