Use OnClick instead of Checked and Unchecked.
Checked and Unchecked are called at weird, unpredictable times by WPF, and saving settings when they happen causes us to change the setting incorrectly. OnClick is only called when the user actually changes the value and not when internal WPF stuff sets it, so it doesn't have this problem.
This commit is contained in:
parent
bb3ee5a0c9
commit
bd052f08ef
@ -126,10 +126,7 @@ namespace smx_config
|
|||||||
|
|
||||||
void CreateThresholdSliders()
|
void CreateThresholdSliders()
|
||||||
{
|
{
|
||||||
// remove the threshold sliders from xaml, create them all here
|
// Remove and recreate threshold sliders.
|
||||||
//
|
|
||||||
// remove the AdvancedModeEnabled binding and ShouldBeDisplayed, handle that here
|
|
||||||
// by creating the ones we need
|
|
||||||
ThresholdSliderContainer.Children.Clear();
|
ThresholdSliderContainer.Children.Clear();
|
||||||
foreach(string sliderName in ThresholdSettings.thresholdSliderNames)
|
foreach(string sliderName in ThresholdSettings.thresholdSliderNames)
|
||||||
{
|
{
|
||||||
|
@ -296,15 +296,18 @@ namespace smx_config
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Checked += delegate(object sender, RoutedEventArgs e) { SaveToSettings(); };
|
|
||||||
Unchecked += delegate(object sender, RoutedEventArgs e) { SaveToSettings(); };
|
|
||||||
|
|
||||||
OnConfigChange onConfigChange;
|
OnConfigChange onConfigChange;
|
||||||
onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
|
onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
|
||||||
LoadFromSettings();
|
LoadFromSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnClick()
|
||||||
|
{
|
||||||
|
IsChecked = !IsChecked;
|
||||||
|
SaveToSettings();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadFromSettings()
|
private void LoadFromSettings()
|
||||||
{
|
{
|
||||||
if(Type == "inner-sensors")
|
if(Type == "inner-sensors")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user