I'm binding the content section of a XAML to an object constructed from a dynamically-created type. The type is generated by a data serializer that I use to transport values to/from web services. Each bound control in the content section is linked to one property in the type. The bindings are defined in the XAML in a typical fashion. So far pretty straight forward stuff.
Now the fun. I need to cross-reference the bound controls with meta-data stored in the serializer. There is separate meta-data for each property stored in the data object. However, when binding to the Text property of a TextBox (or a similar such property for other controls), a custom IValueConverter only provides the binding value and type. It doesn't provide the affected control or the related bound data object or the related property in the bound data object. So as it stands, a IValueConverter doesn't really meet my needs... when used as a XAML-driven converter.
However, by moving the data binding and custom converters out of the XAML and into the code behind, I can then pass a "binding details" object as a parameter to each Binding. This provides the necessary information and solves my issues.
While my solution works, I would have prefered to leave the bindings in the XAML and then reference a "GetBinding" method for each bound control to access the binding information. Unfortunately, there is currently only a SetBinding method. Perhaps in the future, its counterpart will be added. For now, my bass ackwards approach will have to do.
Thanks to everyone for any replies to my posting.
W James
P.S. Yi-Lun, in your example, I see that you reference the value parameter as a class. In my bindings, the value is always presented as a single property from the parent class. Please explain how the value may be passed as a class.