我目前正在使用 AvalonDock2 构建一个简单的 UI。如果我理解正确,LayoutItemTemplate 可用于为所有文档和 achoables 设置模板。
现在这是我的问题:我想要“硬编码”的可锚定模板。锚点看起来像这样:
<avalonDock:LayoutAnchorable Title="Dialogs"
CanClose="False"
CanHide="False"
CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsDialogs}"/>
</avalonDock:LayoutAnchorable>
另一方面,我的中央文档窗格正在通过
DocumentsSource="{Binding Path=Editor.EditingModelObjects}"
对于这些文档,设置模板是有意义的,因此我可以使用 ContentControl 并选择适当的样式,如下所示
<Style x:Key="DocumentStyle" TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Type}" Value="{x:Static Member=integratorCore:ModelObjectType.Npc}">
<DataTrigger.Setters>
<Setter Property="Template" Value="{StaticResource ResourceKey=NpcViewTemplate}"/>
</DataTrigger.Setters>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Type}" Value="{x:Static Member=integratorCore:ModelObjectType.Room}">
<DataTrigger.Setters>
<Setter Property="Template" Value="{StaticResource ResourceKey=RoomViewTemplate}"/>
</DataTrigger.Setters>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Type}" Value="{x:Static Member=integratorCore:ModelObjectType.Dialog}">
<DataTrigger.Setters>
<Setter Property="Template" Value="{StaticResource ResourceKey=DialogViewTemplate}"/>
</DataTrigger.Setters>
</DataTrigger>
</Style.Triggers>
</Style>
现在的问题是,设置 LayoutItemTemplate 会覆盖我的可锚定对象的硬编码内容......
我怎么能同时拥有硬编码的可锚定和模板文档?就像在旧的 AvalonDock 版本中一样,或者我应该如何使用新版本正确处理这个问题?
这是完整的对接管理器:
<avalonDock:DockingManager x:Name="dockingManager"
Grid.Row="2"
DocumentsSource="{Binding Path=Editor.EditingModelObjects}"
DocumentClosing="DockingManagerDocumentClosing">
<avalonDock:DockingManager.Theme>
<avalonDock:ExpressionDarkTheme/>
</avalonDock:DockingManager.Theme>
<!--<avalonDock:DockingManager.LayoutItemTemplate>
<DataTemplate>
<ContentControl Style="{StaticResource LayoutItemStyle}" />
</DataTemplate>
</avalonDock:DockingManager.LayoutItemTemplate>-->
<avalonDock:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Content.Type.Name}"/>
</DataTemplate>
</avalonDock:DockingManager.DocumentHeaderTemplate>
<avalonDock:LayoutRoot>
<avalonDock:LayoutPanel Orientation="Horizontal">
<avalonDock:LayoutAnchorablePane DockWidth="350">
<avalonDock:LayoutAnchorable Title="Dialogs" CanClose="False" CanHide="False" CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsDialogs}"/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="NPCs" CanClose="False" CanHide="False" CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsNpcs}"/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Rooms" CanClose="False" CanHide="False" CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsRooms}"/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="TileSet" CanClose="False" CanHide="False" CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsTileSets}"/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Zones" CanClose="False" CanHide="False" CanFloat="False">
<integratorUI:Explorer DataContext="{Binding Path=Editor.ModelsZones}"/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorablePane>
<avalonDock:LayoutDocumentPane x:Name="documentPane">
</avalonDock:LayoutDocumentPane>
<avalonDock:LayoutAnchorablePane DockWidth="300">
<avalonDock:LayoutAnchorable Title="Context"
CanClose="False"
CanHide="False"
CanFloat="False">
<TextBox/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorablePane>
</avalonDock:LayoutPanel>
<avalonDock:LayoutRoot.BottomSide>
<avalonDock:LayoutAnchorSide>
<avalonDock:LayoutAnchorGroup>
<avalonDock:LayoutAnchorable Title="Console"
CanClose="False"
CanHide="False"
CanFloat="False">
<TextBlock Text="Test"/>
</avalonDock:LayoutAnchorable>
<avalonDock:LayoutAnchorable Title="Error List"
CanClose="False"
CanHide="False"
CanFloat="False">
<TextBlock Text="Test"/>
</avalonDock:LayoutAnchorable>
</avalonDock:LayoutAnchorGroup>
</avalonDock:LayoutAnchorSide>
</avalonDock:LayoutRoot.BottomSide>
</avalonDock:LayoutRoot>
</avalonDock:DockingManager>