XMLDataProvider
-
Just discovered the XMLDataProvider, great! :) My problem this time is the binding. My XML file looks like this...with several products and more than one Coupler per product but with different Id.
<CouplerSettings>
<Product Id="C702">
<Coupler Id="R+S Grid">
<Attenuation Id="GSM850LowChRX" Value="8.9875" />
<Attenuation Id="GSM850LowChTX" Value="7.745" />
<Attenuation Id="GSM850MidChRX" Value="10.7375" />
<Attenuation Id="GSM850MidChTX" Value="8.73375" />
....I select product in a ListBox, based on another file. Then I want to bind a TextBox to a Value with a specific Attenuation Id, that is within the same element. In my code I have
String xpath = "CouplerSettings/Product[@Id='" + productName + "']/Coupler[@Id='R+S Grid']";
XmlDataProvider providerCoupler = new XmlDataProvider();
providerCoupler.Source = new Uri(@"D:\Programming\MyFile.xml");
providerCoupler.XPath = xpath;
WrapPanelCoupler.DataContext = providerCoupler;and in XAML
<WrapPanel Name="WrapPanelCoupler" Grid.Row="2" MaxWidth="800">
<TextBox Name="textbox1" Text="{Binding XPath=???If I select the C702 product and Coupler with Id="R+S Grid" and then want to bind the TextBox text to the Value where i.e the Attenuation Id="GSM850LowChRX", how to do that? If I change the code to
String xpath = "CouplerSettings/Product[@Id='" + productName + "']/Coupler[@Id='R+S Grid']/Attenuation[@Id='GSM850LowChRX']";
and
<TextBox Name="textbox1" Text="{Binding XPath=@Value}
does the trick but I really want the binding to include the Attenuation Id.
-
Just discovered the XMLDataProvider, great! :) My problem this time is the binding. My XML file looks like this...with several products and more than one Coupler per product but with different Id.
<CouplerSettings>
<Product Id="C702">
<Coupler Id="R+S Grid">
<Attenuation Id="GSM850LowChRX" Value="8.9875" />
<Attenuation Id="GSM850LowChTX" Value="7.745" />
<Attenuation Id="GSM850MidChRX" Value="10.7375" />
<Attenuation Id="GSM850MidChTX" Value="8.73375" />
....I select product in a ListBox, based on another file. Then I want to bind a TextBox to a Value with a specific Attenuation Id, that is within the same element. In my code I have
String xpath = "CouplerSettings/Product[@Id='" + productName + "']/Coupler[@Id='R+S Grid']";
XmlDataProvider providerCoupler = new XmlDataProvider();
providerCoupler.Source = new Uri(@"D:\Programming\MyFile.xml");
providerCoupler.XPath = xpath;
WrapPanelCoupler.DataContext = providerCoupler;and in XAML
<WrapPanel Name="WrapPanelCoupler" Grid.Row="2" MaxWidth="800">
<TextBox Name="textbox1" Text="{Binding XPath=???If I select the C702 product and Coupler with Id="R+S Grid" and then want to bind the TextBox text to the Value where i.e the Attenuation Id="GSM850LowChRX", how to do that? If I change the code to
String xpath = "CouplerSettings/Product[@Id='" + productName + "']/Coupler[@Id='R+S Grid']/Attenuation[@Id='GSM850LowChRX']";
and
<TextBox Name="textbox1" Text="{Binding XPath=@Value}
does the trick but I really want the binding to include the Attenuation Id.