Here is my code for some settings
if (settings.Contains("dynamicOn"))
{
// Commenting out because we're trying a different way
// DynamicCheck.IsChecked = (bool)settings["dynamicOn"];
dynamicToggle.IsChecked = (bool)settings["dynamicOn"];
AllPacks.IsChecked = (bool)settings["changeAllPacks"];
}
And here is the XAML behind it
<toolkit:ToggleSwitch x:Name="dynamicToggle" Header="Dynamically Update Lockscreen?" Margin="0,112,0,-112" SwitchForeground="White" Checked="DynamicCheck_Checked_1" Unchecked="DynamicCheck_Unchecked">
<toolkit:ToggleSwitch.HeaderTemplate>
<DataTemplate>
<ContentControl Content="{Binding}"/>
</DataTemplate>
</toolkit:ToggleSwitch.HeaderTemplate>
</toolkit:ToggleSwitch>
<CheckBox x:Name="AllPacks" Content="All Packs" Checked="AllPacks_Checked" Unchecked="AllPacks_Unchecked" Margin="50,174,0,0" Visibility="Collapsed"/>
Now, the XAML works fine, as well as the ToggleSwitch. All that works. Just, when I try to actually open up my settings page (which opens just fine without the CheckBox stuff, but refuses to open with it), I get this error
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.ni.dll The program '[3048] TaskHost.exe' has exited with code -1 (0xffffffff).
Has anyone seen this before? Searching Bing doesn't seem to have anything for me. Any help would be greatly appreciated!
Thanks, Patrick
EDIT: I've changed the code to this
if (settings.Contains("dynamicOn"))
{
// Commenting out because we're trying a different way
// DynamicCheck.IsChecked = (bool)settings["dynamicOn"];
AllPacks.IsChecked = (bool)settings["changeAllPacks"];
dynamicToggle.IsChecked = (bool)settings["dynamicOn"];
}
else
{
// Commenting out because we're trying a different way
// DynamicCheck.IsChecked = true;
// isEnabledText.Visibility = Visibility.Visible;
// settings.Add("dynamicOn", true);
dynamicToggle.IsChecked = true;
AllPacks.IsChecked = true;
AllPacks.Visibility = Visibility.Visible;
settings.Add("changeAllPacks", true);
settings.Add("dynamicOn", true);
}
And now it errors on the
settings.Add("dynamicOn", true);
And the error has also changed to
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll
So, I'm starting to think that this might be an IsolatedStorage issue?