DataBinding with Converter not updating when Context changes.


i have a usercontrol that displays vehicle information (i.e. year, make, model) from custom class inherits inotifypropertychanged (vehicleinfo).  usercontrol uses databinding display in 1 textblock through use of converter class: 
<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

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........