是否可以阻止锚定停靠在我的文档窗格中?我希望它们可以拖动并在屏幕上移动,但有时用户将它们拖到文档窗格中,这使它们看起来很差。然后他们关闭标签,我无法重新打开可锚定的。
如果它有助于我的Avalon代码如下:
<avalonDock:DockingManager.Theme>
<avalonDock:VS2010Theme />
</avalonDock:DockingManager.Theme>
<avalonDock:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal">
<!-- the TextBlock named Limiter is used to limit the height of the TextBlock for the workflow name. -->
<TextBlock x:Name="Limiter" TextWrapping="NoWrap" Visibility="Hidden"
TextTrimming="CharacterEllipsis">
L
</TextBlock>
<TextBlock Text="{Binding Path=Title}" VerticalAlignment="Center"
ToolTip="{StaticResource WorkflowTabItemToolTip}"
MaxHeight="{Binding ActualHeight, ElementName=Limiter}" MaxWidth="150"
TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Margin="0,0,2,0"
AutomationProperties.AutomationId="WorkflowTabTitleText"/>
<TextBlock Text=" *"
ToolTip="Has unsaved changes"
Visibility="{Binding Content.UnsavedEdits, Converter={StaticResource BoolToVis}}"
AutomationProperties.AutomationId="DirtyTabIndicator"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</avalonDock:DockingManager.DocumentHeaderTemplate>
<avalonDock:DockingManager.LayoutItemContainerStyleSelector>
<utilities1:PanesStyleSelector>
<utilities1:PanesStyleSelector.WebUIStyle>
<Style TargetType="{x:Type avalonDock:LayoutAnchorableItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="IconSource" Value="{Binding Model.IconSource}"/>
<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="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/>
<Setter Property="IsActive" Value="{Binding Model.IsActive, Mode=TwoWay}"/>
</Style>
</utilities1:PanesStyleSelector.WebUIStyle>
<utilities1:PanesStyleSelector.DocumentStyle>
<Style TargetType="{x:Type avalonDock:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.WorkflowName}" />
<Setter Property="IsActive" Value="{Binding Model.IsActive}" />
<Setter Property="IsSelected" Value="{Binding Model.IsActive}" />
</Style>
</utilities1:PanesStyleSelector.DocumentStyle>
</utilities1:PanesStyleSelector>
</avalonDock:DockingManager.LayoutItemContainerStyleSelector>
<avalonDock:DockingManager.LayoutItemTemplateSelector>
<utilities1:PanesTemplateSelector>
<utilities1:PanesTemplateSelector.WorkflowDesignerViewTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding}" IsTabStop="False" />
</DataTemplate>
</utilities1:PanesTemplateSelector.WorkflowDesignerViewTemplate>
<utilities1:PanesTemplateSelector.WebUIViewTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding}" IsTabStop="False" />
</DataTemplate>
</utilities1:PanesTemplateSelector.WebUIViewTemplate>
</utilities1:PanesTemplateSelector>
</avalonDock:DockingManager.LayoutItemTemplateSelector>
<avalonDock:LayoutRoot>
<avalonDock:LayoutPanel Orientation="Horizontal">
<avalonDock:LayoutDocumentPaneGroup>
<avalonDock:LayoutDocumentPane AutomationProperties.AutomationId="AvalonDocumentPane"/>
</avalonDock:LayoutDocumentPaneGroup>
<avalonDock:LayoutAnchorablePane DockWidth="800" DockMinWidth="400" AutomationProperties.AutomationId="WebUIPane"/>
<avalonDock:LayoutAnchorablePane DockWidth="225" DockMinWidth="225" AutomationProperties.AutomationId="ActivitiesPane">
<avalonDock:LayoutAnchorable Title="Activities" AutoHideWidth="225" AutoHideMinWidth="225" CanClose="False" CanHide="False">
<toolbox:ToolboxControl Name="Toolbox" AutomationProperties.AutomationId="ActivitiesToolbox"
utilities1:ToolboxItemSource.ToolboxItems="{Binding ToolboxList}" />
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorablePane>
</avalonDock:LayoutPanel>
</avalonDock:LayoutRoot>
</avalonDock:DockingManager>
答案 0 :(得分:2)
虽然我没有找到防止对接的直接方法,但我能够解决基本问题,即为工具窗口和文档窗口自定义不同的选项卡标题。我的文档窗口在选项卡标题中显示星号(*)以指示更改(就像VS),而工具窗口不应该这样做。
解决方案是使用DocumentHeaderTemplateSelector
并为其提供两个不同的模板,每个模板用于文档和工具窗口。这是XAML:
<xcad:DockingManager.DocumentHeaderTemplateSelector>
<bd:DocumentHeaderTemplateSelector>
<bd:DocumentHeaderTemplateSelector.DocumentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="Resources\AppIcon.ico" Margin="0,0,4,0" Width="16" />
<TextBlock Text="{Binding Title}" />
<TextBlock Text=" *" Visibility="{Binding Content.IsDirty, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
</DataTemplate>
</bd:DocumentHeaderTemplateSelector.DocumentTemplate>
<bd:DocumentHeaderTemplateSelector.ToolWindowTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</bd:DocumentHeaderTemplateSelector.ToolWindowTemplate>
</bd:DocumentHeaderTemplateSelector>
</xcad:DockingManager.DocumentHeaderTemplateSelector>
选择器类只是:
Public Class DocumentHeaderTemplateSelector
Inherits DataTemplateSelector
Public Property DocumentTemplate As DataTemplate
Public Property ToolWindowTemplate As DataTemplate
Public Overrides Function SelectTemplate(item As Object, container As System.Windows.DependencyObject) As System.Windows.DataTemplate
Dim itemAsLayoutContent = TryCast(item, Xceed.Wpf.AvalonDock.Layout.LayoutContent)
If TypeOf item Is Xceed.Wpf.AvalonDock.Layout.LayoutDocument AndAlso TypeOf DirectCast(item, Xceed.Wpf.AvalonDock.Layout.LayoutDocument).Content Is DocumentVM Then
Return DocumentTemplate
Else
Return ToolWindowTemplate
End If
End Function
End Class
现在我的工具窗口不显示星号(*)和图标,即使它们已移动到文档窗格中。
希望这可以帮助有人在路上。