AvalonDock 的自动隐藏宽度
AutoHideWidth for AvalonDock
我有一个 AvalonDock 2
和 LayoutAnchorablePane
如下所示,
<xcad:DockingManager
AnchorablesSource="{Binding AnchorableSource}"
DocumentsSource="{Binding DocumentSource}"
Utility:AvalonDockLayoutSerializer.LoadLayoutCommand="{Binding LoadLayoutCommand}"
Utility:AvalonDockLayoutSerializer.SaveLayoutCommand="{Binding SaveLayoutCommandOnExit}">
<xcad:DockingManager.Theme>
<xcad:MetroTheme />
</xcad:DockingManager.Theme>
<xcad:DockingManager.LayoutUpdateStrategy>
<Pane:LayoutInitializer/>
</xcad:DockingManager.LayoutUpdateStrategy>
<xcad:DockingManager.Resources>
<DataTemplate DataType="{x:Type ViewModels:ExplorerViewModel}">
<Views:ExplorerView />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:TableOfContentViewModel}">
<Views:TableOfContentView x:Name="TOCView" Focusable="True">
<Views:TableOfContentView.InputBindings>
<KeyBinding Key="F5" Command="{Binding GridF5Command}"/>
</Views:TableOfContentView.InputBindings>
</Views:TableOfContentView>
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:PropertyViewModel}">
<Views:PropertyView />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:SearchViewModel}">
<Views:SearchPanel />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:DocumentViewModel}">
<Views:DocumentView />
</DataTemplate>
</xcad:DockingManager.Resources>
<xcad:DockingManager.LayoutItemContainerStyleSelector>
<Pane:PanesStyleSelector>
<Pane:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type xcad:LayoutAnchorableItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
<Setter Property="FlowDirection" Value="LeftToRight"/>
<Setter Property="UseLayoutRounding" Value="False"/>
</Style>
</Pane:PanesStyleSelector.ToolStyle>
<Pane:PanesStyleSelector.FileStyle>
<Style TargetType="{x:Type xcad:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="ToolTip" Value="{Binding Model.FilePath}"/>
<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
<Setter Property="CanClose" Value="False"/>
</Style>
</Pane:PanesStyleSelector.FileStyle>
</Pane:PanesStyleSelector>
</xcad:DockingManager.LayoutItemContainerStyleSelector>
<xcad:LayoutRoot>
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane Name="Explorer" DockMinWidth="200" FloatingWidth="200"/>
<xcad:LayoutAnchorablePane Name="TOC" DockMinWidth="630"/>
<xcad:LayoutAnchorablePaneGroup Orientation="Vertical" DockMinWidth="300">
<xcad:LayoutAnchorablePane Name="Property" />
<xcad:LayoutAnchorablePane Name="Search" />
</xcad:LayoutAnchorablePaneGroup>
<xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPane>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
如何为 LayoutAnchorable
.
设置 AutoHideMinWidth
和 AutoHideMinHeight
不幸的是,LayoutAnchorable
或 LayoutAnchorablePane
都不是 FramworkElement
,因此您不能应用全局样式来设置 AutoHideMinWidth
和 AutoHideMinHeight
属性,
您唯一的选择是下载 AvalonDock 2.0 源代码:
http://avalondock.codeplex.com/SourceControl/latest#Version2.0/
将项目添加并引用到您的解决方案。 在 Xceed.Wpf.AvalonDock 项目 /Layout/LayoutAnchorable.cs 下,将 AutoHideMinWidth
和 AutoHideMinHeight
默认值更新为最适合您的值。
#region AutoHideMinWidth
private double _autohideMinWidth = 100.0; //default value
public double AutoHideMinWidth
{
get { return _autohideMinWidth; }
set
{
if (_autohideMinWidth != value)
{
RaisePropertyChanging("AutoHideMinWidth");
if (value < 0)
throw new ArgumentException("value");
_autohideMinWidth = value;
RaisePropertyChanged("AutoHideMinWidth");
}
}
}
我有一个 AvalonDock 2
和 LayoutAnchorablePane
如下所示,
<xcad:DockingManager
AnchorablesSource="{Binding AnchorableSource}"
DocumentsSource="{Binding DocumentSource}"
Utility:AvalonDockLayoutSerializer.LoadLayoutCommand="{Binding LoadLayoutCommand}"
Utility:AvalonDockLayoutSerializer.SaveLayoutCommand="{Binding SaveLayoutCommandOnExit}">
<xcad:DockingManager.Theme>
<xcad:MetroTheme />
</xcad:DockingManager.Theme>
<xcad:DockingManager.LayoutUpdateStrategy>
<Pane:LayoutInitializer/>
</xcad:DockingManager.LayoutUpdateStrategy>
<xcad:DockingManager.Resources>
<DataTemplate DataType="{x:Type ViewModels:ExplorerViewModel}">
<Views:ExplorerView />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:TableOfContentViewModel}">
<Views:TableOfContentView x:Name="TOCView" Focusable="True">
<Views:TableOfContentView.InputBindings>
<KeyBinding Key="F5" Command="{Binding GridF5Command}"/>
</Views:TableOfContentView.InputBindings>
</Views:TableOfContentView>
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:PropertyViewModel}">
<Views:PropertyView />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:SearchViewModel}">
<Views:SearchPanel />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModels:DocumentViewModel}">
<Views:DocumentView />
</DataTemplate>
</xcad:DockingManager.Resources>
<xcad:DockingManager.LayoutItemContainerStyleSelector>
<Pane:PanesStyleSelector>
<Pane:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type xcad:LayoutAnchorableItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
<Setter Property="FlowDirection" Value="LeftToRight"/>
<Setter Property="UseLayoutRounding" Value="False"/>
</Style>
</Pane:PanesStyleSelector.ToolStyle>
<Pane:PanesStyleSelector.FileStyle>
<Style TargetType="{x:Type xcad:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="ToolTip" Value="{Binding Model.FilePath}"/>
<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
<Setter Property="CanClose" Value="False"/>
</Style>
</Pane:PanesStyleSelector.FileStyle>
</Pane:PanesStyleSelector>
</xcad:DockingManager.LayoutItemContainerStyleSelector>
<xcad:LayoutRoot>
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane Name="Explorer" DockMinWidth="200" FloatingWidth="200"/>
<xcad:LayoutAnchorablePane Name="TOC" DockMinWidth="630"/>
<xcad:LayoutAnchorablePaneGroup Orientation="Vertical" DockMinWidth="300">
<xcad:LayoutAnchorablePane Name="Property" />
<xcad:LayoutAnchorablePane Name="Search" />
</xcad:LayoutAnchorablePaneGroup>
<xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPane>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
如何为 LayoutAnchorable
.
AutoHideMinWidth
和 AutoHideMinHeight
不幸的是,LayoutAnchorable
或 LayoutAnchorablePane
都不是 FramworkElement
,因此您不能应用全局样式来设置 AutoHideMinWidth
和 AutoHideMinHeight
属性,
您唯一的选择是下载 AvalonDock 2.0 源代码:
http://avalondock.codeplex.com/SourceControl/latest#Version2.0/
将项目添加并引用到您的解决方案。 在 Xceed.Wpf.AvalonDock 项目 /Layout/LayoutAnchorable.cs 下,将 AutoHideMinWidth
和 AutoHideMinHeight
默认值更新为最适合您的值。
#region AutoHideMinWidth
private double _autohideMinWidth = 100.0; //default value
public double AutoHideMinWidth
{
get { return _autohideMinWidth; }
set
{
if (_autohideMinWidth != value)
{
RaisePropertyChanging("AutoHideMinWidth");
if (value < 0)
throw new ArgumentException("value");
_autohideMinWidth = value;
RaisePropertyChanged("AutoHideMinWidth");
}
}
}