I've been trying to bind XML (via an XElement) to a DataGrid dynamically in Silverlight (specifically Silverlight 4, but any solutions in SL3 would be fine too) but have been unable to do so. I hope to do this dynamically (ie - no rigid business objects to represent the XML).
What I'm hoping for in the end is a way to bind to any XElement containing arbitrary XML, and then use some sort of IConverter to transform the XElement into something the DataGrid can bind to - and just "know" how to auto-generate columns and rows from the converted object.
<sdk:DataGrid
ItemsSource="{Binding Source={StaticResource MyViewModel},
Path=MyXElement, Converter={SomeConverter}}" AutoGenerateColumns="True">
If possible, I'd like to be able to utilize some sort of reusable declarative component (trying to avoid code-behind on actual Views).
I've tried using DynamicObjects, but the DataGrid can't figure out its properties. Any other suggestions would be welcome. Thanks.