From a9fafbe40f2ebf1c0f4d4b5810a0ad77ab231d8d Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 9 Mar 2014 20:39:35 +0100 Subject: [PATCH] StorageLocationPicker: fix switching from a configuration-specific location to the base location. The CoerceValue-callback is not called by WPF for values set by the control itself, so it was setting ProjectProperty.Location to PropertyStorageLocations.Unchanged instead of PropertyStorageLocations.Base. --- .../ProjectOptions/StorageLocationPicker.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs index 9bbcc45a46..7192796685 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/StorageLocationPicker.cs @@ -79,7 +79,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels static object CoerceLocation(DependencyObject d, object baseValue) { - PropertyStorageLocations location = (PropertyStorageLocations)baseValue; + return CoerceLocation((PropertyStorageLocations)baseValue); + } + + static PropertyStorageLocations CoerceLocation(PropertyStorageLocations location) + { if ((location & PropertyStorageLocations.ConfigurationAndPlatformSpecific) != 0) { // remove 'Base' flag if any of the specific flags is set location &= ~PropertyStorageLocations.Base; @@ -132,9 +136,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels item.SetValueToExtension(MenuItem.HeaderProperty, new StringParseExtension(text)); item.Click += delegate(object sender, RoutedEventArgs e) { if ((this.Location & location) == 0) { - this.Location |= location; + SetCurrentValue(LocationProperty, CoerceLocation(this.Location | location)); } else { - this.Location &= ~location; + SetCurrentValue(LocationProperty, CoerceLocation(this.Location & ~location)); } e.Handled = true; };