We are loading some xaml for an Element at runtime (XamlReader.Load) for some preview purposes. Need less to say, the properties/bindings are not know as they can vary across elements/controls we are loading.
As the run time view model context is not available when we load the control for preview – after loading the Element, the idea is to grab the binding information, create a type with those propertes at run time, to assign the same as the data context of the loaded control.
We’ll be using AssemblyBuilder/ModuleBuilder/TypeBuilder to build a type at run time. Having said that, we need to walk the visual tree to identify the bindings involved, to create a list of binding paths.
Obviously, one way is to use regex to parse the xaml directly and build this list.. Just want to know a way exist so that I can grab the bindings and related paths from the visual tree itself?
Thanks
Why not just walk the Silverlight Visual Tree and for each element call GetBindingExpression() for all of it’s DPs?