I figured out the issue... XAML does not handle %
in a file path as expected. To correct, I removed the following from my XAML XmlDataProvider
declaration:
Source="%appdata%\Vulnerator\Vulnerator_Config.xml"
XPath="prefRoot"
I then set the Source
and XPath
properties in my code-behind (.xaml.cs):
public MainWindow()
{
InitializeComponent();
Uri xmlPath = new Uri (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Vulnerator\Vulnerator_Config.xml");
(this.Resources["XmlConfig"] as XmlDataProvider).Source = xmlPath;
(this.Resources["XmlConfig"] as XmlDataProvider).XPath = "prefRoot";
}
Now, when the application loads, the checkbox is set to the inner value of the XML node specified. Also, I set the Binding Mode=TwoWay
to OneTime
; two way binding to an XmlDataProvider doesn't occur as expected. To get around this, I am going to bind a command to the Checkbox to update a Dictionary<string, string>
(created at startup in my view-model constructer) with the new IsChecked
value. I will use the Dictionary
to control what the application does based off of user input, and write the new Dictionary
user values to the XML file once the application is closed.