Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Handle CanClose and CanHide in XAML #188

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Aero/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock

Expand Down Expand Up @@ -1059,9 +1059,23 @@
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>


</ControlTemplate.Triggers>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Expression/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock

Expand Down Expand Up @@ -926,9 +926,23 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</Trigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="/AvalonDock.Themes.Expression;component/Images/PinClose_Light.png" />
</Trigger>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.Metro/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock

Expand Down Expand Up @@ -1088,9 +1088,23 @@
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Dark.png" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Black.png" />
</Trigger>
Expand Down
20 changes: 17 additions & 3 deletions source/Components/AvalonDock.Themes.VS2010/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock

Expand Down Expand Up @@ -1134,9 +1134,23 @@
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Dark.png" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
<Trigger SourceName="DocumentCloseButton" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_ImgPinClose" Property="Source" Value="Images/PinClose_Black.png" />
</Trigger>
Expand Down
18 changes: 16 additions & 2 deletions source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,23 @@
<DataTrigger Binding="{Binding Path=IsActive}" Value="true">
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>

<!-- Document Well : Tab : Button / Selected, inactive -->
<MultiDataTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
checkPreviousContainer = false;
}

anchorableToImport.SetCanCloseInternal(true);
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//anchorableToImport.SetCanCloseInternal(true);

paneModel.Children.Insert(i, anchorableToImport);
i++;
Expand Down Expand Up @@ -606,4 +607,4 @@ public override Geometry GetPreviewPath(OverlayWindow overlayWindow,

#endregion Overrides
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
int i = 0;
foreach (var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType<LayoutAnchorable>().ToArray())
{
anchorableToImport.SetCanCloseInternal(true);
// BD: 18.07.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//anchorableToImport.SetCanCloseInternal(true);

paneModel.Children.Insert(i, anchorableToImport);
i++;
Expand Down Expand Up @@ -145,4 +146,4 @@ public override Geometry GetPreviewPath(OverlayWindow overlayWindow,

#endregion Overrides
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@ private void UpdateDragDetails()
private void StartDraggingFloatingWindowForContent()
{
ReleaseMouseCapture();
if (Model is LayoutAnchorable layoutAnchorable) layoutAnchorable.ResetCanCloseInternal();
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//if (Model is LayoutAnchorable layoutAnchorable) layoutAnchorable.ResetCanCloseInternal();
var manager = Model.Root.Manager;
manager.StartDraggingFloatingWindowForContent(Model);
}

#endregion Private Methods
}
}
}
26 changes: 14 additions & 12 deletions source/Components/AvalonDock/Layout/LayoutAnchorable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
AvalonDock

Copyright (C) 2007-2013 Xceed Software Inc.
Expand Down Expand Up @@ -34,7 +34,8 @@ public class LayoutAnchorable : LayoutContent
private bool _canHide = true;
private bool _canAutoHide = true;
private bool _canDockAsTabbedDocument = true;
private bool _canCloseValueBeforeInternalSet;
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//private bool _canCloseValueBeforeInternalSet;
private bool _canMove = true;

#endregion fields
Expand Down Expand Up @@ -575,16 +576,17 @@ internal void CloseAnchorable()
CloseInternal();
}

internal void SetCanCloseInternal(bool canClose)
{
_canCloseValueBeforeInternalSet = _canClose;
_canClose = canClose;
}
// BD: 17.08.2020 Remove that bodge and handle CanClose=false && CanHide=true in XAML
//internal void SetCanCloseInternal(bool canClose)
//{
// _canCloseValueBeforeInternalSet = _canClose;
// _canClose = canClose;
//}

internal void ResetCanCloseInternal()
{
_canClose = _canCloseValueBeforeInternalSet;
}
//internal void ResetCanCloseInternal()
//{
// _canClose = _canCloseValueBeforeInternalSet;
//}

#endregion Internal Methods

Expand All @@ -608,4 +610,4 @@ private void UpdateParentVisibility()

#endregion Private Methods
}
}
}
20 changes: 17 additions & 3 deletions source/Components/AvalonDock/Themes/generic.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
************************************************************************
AvalonDock

Expand Down Expand Up @@ -799,9 +799,23 @@
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Visible" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=CanClose}" Value="false">
<!--BD: 17.08.2020 use HideCommand if CanClose=false but CanHide=true-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Command" Value="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter TargetName="DocumentCloseButton" Property="ToolTip" Value="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" />
</MultiDataTrigger>
<!--BD: 17.08.2020 hide button if both CanClose=false and CanHide=false-->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=CanClose}" Value="false" />
<Condition Binding="{Binding Path=CanHide}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="DocumentCloseButton" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down