How to switch between document tabs in AvalonDock 2

故事扮演 提交于 2019-12-13 01:35:07

问题


I have build a little app that uses AvalonDock 2. I bound my view models to the docking manager, can create and remove documents, all fine. However, there is one thing I do net get to work: When I have multiple documents open I am not able to make a specific document tab the active and visible tab (like if I would click on the tab header) from code.

I have bound to the "ActiveContent" property and set it to the document I want to be the active and visible one, but that does not help.

Can please someone give me some advice on how to do that?


回答1:


After some research it turned out to be a trivial task. The actual problem is lack of documentation on such trivial tasks. So here for all others who fight with the same problem, the answer:

Each LayoutItem has a property named IsSelected. By setting its value to 'true', the tab representing the LayoutItem is switched into view.




回答2:


Here is a non MMVM solution to making a Layout the active or selected layout in AvalonDock 2.

Code below written in the same class as your XAML MainWindow where "mainPanel" is the name of your LayoutDocumentPane.

XAML

<xcad:LayoutDocumentPane x:Name="mainPanel">

Code Behind:

public void MakeActiveLayout(String layoutTitle)
{
    foreach (LayoutDocument child in mainPanel.Children)
    {
        if(child.Title == layoutTitle)
        {
            child.IsSelected = true;
        }
    }
}


来源:https://stackoverflow.com/questions/33918513/how-to-switch-between-document-tabs-in-avalondock-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!