This is a 2 part question.
1) Is it possible to bind XDocument to a WPF control without using ObjectDataProvider ?
Here is a snippet of my code in which XmlDocument works, but i cannot use XDocument
XmlDataProvider provider = new XmlDataProvider();
provider.XPath = "/Parent/Child";
provider.Document = mydoc; // xmldocument works fine.
Binding binding = new Binding();
binding.XPath = "InnerChild/Name";
binding.Source = provider;
decisionCb.SetBinding(ComboBox.ItemsSourceProperty, binding);
I need to retain the ability to bind using an XPath because my Xml document is generated on the fly. I wanted to use XDocument and LINQ :(
2) Is it possible to use XPath extension functions in XElement within Xaml ?
<DataTemplate DataType="{}{http://myns}Child" >
<StackPanel Orientation="Horizontal">
<!-- This wont work because Element cannot accept XPath -->
<TextBlock Text="{Binding Path=Element[{http://myns}InnerChild/Name]}" />
</StackPanel>
</DataTemplate>