diff --git a/source/Components/AvalonDock/Layout/LayoutAnchorable.cs b/source/Components/AvalonDock/Layout/LayoutAnchorable.cs index 60eef8ad..af3201cc 100644 --- a/source/Components/AvalonDock/Layout/LayoutAnchorable.cs +++ b/source/Components/AvalonDock/Layout/LayoutAnchorable.cs @@ -45,7 +45,9 @@ public class LayoutAnchorable : LayoutContent public LayoutAnchorable() { // LayoutAnchorable will hide by default, not close. - _canClose = false; + // BD: 14.08.2020 Inverting both _canClose and _canCloseDefault to false as anchorables are only hidden but not closed + // That would allow CanClose to be properly serialized if set to true for an instance of LayoutAnchorable + _canClose = _canCloseDefault = false; } #endregion Constructors @@ -608,4 +610,4 @@ private void UpdateParentVisibility() #endregion Private Methods } -} \ No newline at end of file +} diff --git a/source/Components/AvalonDock/Layout/LayoutContent.cs b/source/Components/AvalonDock/Layout/LayoutContent.cs index 92c2dbd2..1b6d2680 100644 --- a/source/Components/AvalonDock/Layout/LayoutContent.cs +++ b/source/Components/AvalonDock/Layout/LayoutContent.cs @@ -425,7 +425,10 @@ public ImageSource IconSource #region CanClose - internal bool _canClose = true; + // BD: 14.08.2020 added _canCloseDefault to properly implement inverting _canClose default value in inheritors (e.g. LayoutAnchorable) + // Thus CanClose property will be serialized only when not equal to its default for given class + // With previous code it was not possible to serialize CanClose if set to true for LayoutAnchorable instance + internal bool _canClose = true, _canCloseDefault = true; public bool CanClose { @@ -557,7 +560,10 @@ public virtual void WriteXml(System.Xml.XmlWriter writer) if (FloatingHeight != 0.0) writer.WriteAttributeString(nameof(FloatingHeight), FloatingHeight.ToString(CultureInfo.InvariantCulture)); if (IsMaximized) writer.WriteAttributeString(nameof(IsMaximized), IsMaximized.ToString()); - if (!CanClose) writer.WriteAttributeString(nameof(CanClose), CanClose.ToString()); + // BD: 14.08.2020 changed to check CanClose value against the default in _canCloseDefault + // thus CanClose property will be serialized only when not equal to its default for given class + // With previous code it was not possible to serialize CanClose if set to true for LayoutAnchorable instance + if (CanClose != _canCloseDefault) writer.WriteAttributeString(nameof(CanClose), CanClose.ToString()); if (!CanFloat) writer.WriteAttributeString(nameof(CanFloat), CanFloat.ToString()); if (LastActivationTimeStamp != null) writer.WriteAttributeString(nameof(LastActivationTimeStamp), LastActivationTimeStamp.Value.ToString(CultureInfo.InvariantCulture)); @@ -757,4 +763,4 @@ protected virtual void InternalDock() #endregion Internal Methods } -} \ No newline at end of file +}