I want to bind the data from my XML file to my userControl.
So far I have:
XML file:
<?xml version="1.0" encoding="utf-8"?>
<testData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<pumps>
<pump>
<speed value="1200"/>
<color value="Black"/>
<heightAndWidth size="50"/>
</pump>
</pumps>
</testData>
App.xaml
<Application.Resources>
<XmlDataProvider x:Key="testDataDataSource" Source="Desktop\testData.xml" d:IsDataSource="True"/>
</Application.Resources>
UserControl:
<Grid x:Name="LayoutRoot">
<Rectangle x:Name="rect" Fill="{Binding XPath=color}" />
<TextBlock x:Name="line1" Text="{Binding XPath=speed}" />
</Grid>
And MainWindow.xaml
<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource testDataDataSource}}">
<local:RectangleControl DataContext="{Binding Mode=Default, XPath=/testData/pumps/pump}" />
</Grid>
However binding is not working. Could you point out what I am doing wrong.