Hi~~~
I look up many samples about XmlDataProvider.
But I found a problem.
If I add a XmlDataProvider in XML and want to C# code to access it. It
doesn't work.
But if I add a control or menu and assign this XmlDataProvider to its
DataContext.
Then the code works.
<!-- Sample XML -->
<XmlDataProvider x:Key="menuData">
<x:XData>
<Items xmlns="">
<Item Title="Foo..." GroupName="First Group">
<Item Title="A"/>
<Item Title="B"/>
<Item Title="C"/>
</Item>
<Item Title="Crimp" GroupName="Another Group" />
<Item Title="Splange" GroupName="Another Group" />
<Item Title="Frobnicate..." GroupName="Another One" />
<Item Title="Do stuff" GroupName="First Group" />
<Item Title="Mangle" GroupName="First Group" />
</Items>
</x:XData>
</XmlDataProvider>
....
<Menu DataContext="{StaticResource menuData}"/> <!-- if i remove this
line, then code doesn't work -->
// Code
XmlDataProvider xdp = FindResource("menuData") as XmlDataProvider;
if( xdp.Data == null )
MessageBox.Show("Data is not loaded");
I guess there's some initialized actions for XmlDataProvider by XAML
intrepreter.
But I can't find the mappings code or what should I write to let the
XmlDataProvider works.
Thank you for reading
BR,
HolaMan



