I have the following in my app. config file
<appSettings>
<add key="Path" value="C:\Users\dave\Desktop\dave"/>
</appSettings>
in my XAML file, the XmlDataProvider is as follows:
<XmlDataProvider x:Name="Data" Source= "setting.xml" XPath="Product" />
I would like to point the Source to Path.
Any help as always is much appreciated.
Kind regards
if you dont mind having a property in code behind, you can use StringFormat
in the xaml
public string MyPath
{
get { return ConfigurationManager.AppSettings["Path"]; }
}
<XmlDataProvider x:Name="Data" Source="{Binding Path=MyPath, StringFormat={}{0}\\Settings.xml}" XPath="Product" />
returns: "C:\\Users\\dave\\Desktop\\dave\\Settings.xml"
Try like this:
<XmlDataProvider x:Name="Data" Source= "pack://siteoforigin:,,,/setting.xml" XPath="Product" />
setting.xml must be in your main folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.