AvalonDock-如何为所有锚点禁用自动隐藏功能

时间:2018-11-29 19:29:46

标签: c# wpf xaml mvvm avalondock

我希望从AvalonDock的使用中删除“自动隐藏”功能。我在此示例之后对解决方案建模:http://lostindetails.com/blog/post/AvalonDock-2.0-with-MVVM

我目前的想法是,如果我可以同时从选项卡(“关闭X”旁边的符号)和上下文菜单中删除该选项,则用户将无法执行隐藏操作。如果还有另一种方法可以完成隐藏操作的删除,那也可以。

从选项卡和上下文菜单中删除隐藏

在该示例中,他能够在export const getCount = createSelector( getCounterValue, (counter, props) => counter * props.multiply ); this.counter = this.store.pipe( select(fromRoot.getCount, { multiply: 2 }) ); 上设置CanClose属性,从而影响由于位于LayoutItem内而显示的任何项目。我想做同样的事情,但是对于DocumentsSourceCanHide来说,它会影响CanAutoHide内部的Anchorables。

编辑:我添加了以下行:

AnchorablesSource

现在让我到达一半。该行删除了隐藏功能,但是没有删除“ AutoHide”图钉符号(或上下文菜单选项)。我知道<Setter Property="dockctrl:LayoutAnchorableItem.CanHide" Value="False" /> 属性确实存在,只是不确定如何设置。这是相关的docs from Xceed

当前解决方案

CanAutoHide

1 个答案:

答案 0 :(得分:1)

  1. 您将不得不重新设置AvalonDock的某些元素的样式,以摆脱AutoHide引脚的影响。以下是来自Generic.xaml AchorablePaneTitle 样式的示例XAML。

  2. 作为替代解决方案:您还可以通过在this sample application中设置CanAutoHide="False" and CanHide="False"来使Pin消失。

更改后的XAML如下

<avalonDock:LayoutAnchorable x:Name="WinFormsWindow"
                             ContentId="WinFormsWindow"
                             Title="WinForms Window"
                             ToolTip="My WinForms Tool"
                             CanAutoHide="False"
                             CanHide="False"
                             CanClose="False" >
    <winformsIntegration:WindowsFormsHost x:Name="winFormsHost" Background="White"/>
</avalonDock:LayoutAnchorable>

这是上面链接的示例应用程序中的屏幕截图。请注意 Winforms窗口上缺少的图钉。 enter image description here

重写AnchorablePaneTitle样式以摆脱在PART_AutoHidePin中定义的引脚(例如:在其上设置Visibility = "Collapsed")。

  <Style TargetType="avalonDockControls:AnchorablePaneTitle">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
              </Grid.ColumnDefinitions>
              <avalonDockControls:DropDownControlArea DropDownContextMenu="{Binding Model.Root.Manager.AnchorableContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
                                                      DropDownContextMenuDataContext="{Binding Path=LayoutItem, RelativeSource={RelativeSource TemplatedParent}}">
                <ContentPresenter Content="{Binding Model, RelativeSource={RelativeSource TemplatedParent}}"
                                  ContentTemplate="{Binding Model.Root.Manager.AnchorableTitleTemplate, RelativeSource={RelativeSource TemplatedParent}}"
                                  ContentTemplateSelector="{Binding Model.Root.Manager.AnchorableTitleTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" />
              </avalonDockControls:DropDownControlArea>

              <avalonDockControls:DropDownButton Style="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}"
                                                 Focusable="False"
                                                 Grid.Column="1"
                                                 DropDownContextMenu="{Binding Model.Root.Manager.AnchorableContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
                                                 DropDownContextMenuDataContext="{Binding Path=LayoutItem, RelativeSource={RelativeSource TemplatedParent}}"
                                                 ToolTip="{x:Static avalonDockProperties:Resources.Anchorable_CxMenu_Hint}">
                <Border Background="White">
                  <Image Source="/Xceed.Wpf.AvalonDock;component/Themes/Generic/Images/PinMenu.png">
                  </Image>
                </Border>
              </avalonDockControls:DropDownButton>

              <Button x:Name="PART_AutoHidePin"
                      Grid.Column="2"
                      Focusable="False"
                      Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                      Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                      Command="{Binding Path=LayoutItem.AutoHideCommand, RelativeSource={RelativeSource TemplatedParent}}"
                      ToolTip="{x:Static avalonDockProperties:Resources.Anchorable_BtnAutoHide_Hint}">
                <Border Background="White">
                  <Image Source="/Xceed.Wpf.AvalonDock;component/Themes/Generic/Images/PinAutoHide.png">
                  </Image>
                </Border>
              </Button>

              <Button x:Name="PART_HidePin"
                      Grid.Column="3"
                      Focusable="False"
                      Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                      Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                      Command="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}"
                      ToolTip="{x:Static avalonDockProperties:Resources.Anchorable_BtnClose_Hint}">
                <Border Background="White">
                  <Image Source="/Xceed.Wpf.AvalonDock;component/Themes/Generic/Images/PinClose.png">
                  </Image>
                </Border>
              </Button>


            </Grid>
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Model.IsAutoHidden, RelativeSource={RelativeSource Mode=Self}}"
                         Value="True">
              <Setter Property="LayoutTransform"
                      TargetName="PART_AutoHidePin">
                <Setter.Value>
                  <RotateTransform Angle="90" />
                </Setter.Value>
              </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Model.CanClose, RelativeSource={RelativeSource Mode=Self}}"
                         Value="True">
              <Setter Property="Command"
                      TargetName="PART_HidePin"
                      Value="{Binding Path=LayoutItem.CloseCommand, RelativeSource={RelativeSource TemplatedParent}}" />
              <Setter Property="ToolTip"
                      TargetName="PART_HidePin"
                      Value="{x:Static avalonDockProperties:Resources.Document_Close}" />

            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>