AvalonDock如何访问代码中的视图模型

时间:2019-04-25 13:34:01

标签: viewmodel access avalondock

你好,我必须遵循以下代码

       <xcad:DockingManager AnchorablesSource="{Binding Anchorables}" DocumentsSource="{Binding Documents}">

            <xcad:DockingManager.LayoutItemTemplateSelector>
                <avalonDock:PanesTemplateSelector>
                    <avalonDock:PanesTemplateSelector.ShellViewTemplate>
                        <DataTemplate>
                            <avalonDock:ShellUserControl x:Name="ShellUserControl" />
                        </DataTemplate>
                    </avalonDock:PanesTemplateSelector.ShellViewTemplate>
                    <avalonDock:PanesTemplateSelector.VariantsViewTemplate>
                        <DataTemplate>
                            <avalonDock:VariantsUserControl x:Name="VariantsUserControl" />
                        </DataTemplate>
                    </avalonDock:PanesTemplateSelector.VariantsViewTemplate>
                </avalonDock:PanesTemplateSelector>
            </xcad:DockingManager.LayoutItemTemplateSelector>

            <xcad:DockingManager.LayoutItemContainerStyleSelector>
                <avalonDock:PanesStyleSelector>
                    <avalonDock:PanesStyleSelector.VariantsStyle>
                        <Style TargetType="{x:Type xcad:LayoutItem}">
                            <Setter Property="Title" Value="{Binding Model.Title}" />
                            <Setter Property="CanClose" Value="False" />
                            <Setter Property="CanFloat" Value="False" />
                        </Style>
                    </avalonDock:PanesStyleSelector.VariantsStyle>
                    <avalonDock:PanesStyleSelector.ShellStyle>
                        <Style TargetType="{x:Type xcad:LayoutAnchorableItem}">
                            <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
                            <Setter Property="Title" Value="{Binding Model.Title}" />
                        </Style>
                    </avalonDock:PanesStyleSelector.ShellStyle>
                </avalonDock:PanesStyleSelector>
            </xcad:DockingManager.LayoutItemContainerStyleSelector>

            <xcad:LayoutRoot>
                <xcad:LayoutPanel Orientation="Vertical">
                    <xcad:LayoutDocumentPane ShowHeader="False" />
                    <xcad:LayoutAnchorablePane DockHeight="160" />
                </xcad:LayoutPanel>
            </xcad:LayoutRoot>
        </xcad:DockingManager>

如何在代码中访问VariantsUserControl的视图模型? 我不知道如何检索用户控件的DataContext。

感谢Urs

0 个答案:

没有答案