2015-11-16 20 views
0

我试图以编程方式使用下面的代码创建一个标签栏里面两个窗格:Xceed.Wpf.AvalonDock:创建标签窗格编程

var middlePanel = new LayoutPanel 
{ 
    Orientation = Orientation.Vertical, 
    DockHeight = new GridLength(250) 
}; 
rootPanel.Children.Add(middlePanel); 

var paneGroup = new LayoutAnchorablePaneGroup 
{ 
    DockHeight = new GridLength(200) 
}; 
middlePanel.Children.Add(new LayoutDocumentPane()); 
middlePanel.Children.Add(paneGroup); 

var validationEditorPane = new LayoutAnchorablePane(); 
paneGroup.Children.Add(validationEditorPane); 
validationEditorPane.Children.Add(new LayoutAnchorable { ContentId = "Validation", Title = "Validation" }); 

var searchEditorPane = new LayoutAnchorablePane(); 
paneGroup.Children.Add(searchEditorPane); 
searchEditorPane.Children.Add(new LayoutAnchorable { ContentId = "Search", Title = "Search" }); 

然而,上面的代码创建了两个窗格旁边的每个其他没有标签。在运行期间,我可以将“搜索”窗格拖到“验证”窗格上以将它们移动到标签中。这表明它必须有可能以编程方式实现,但我看不出如何。

有什么建议吗?

回答

0

结果比我想象的要容易。我所要做的就是将LayoutAnchorable s添加到同一LayoutAnchorablePane对象:

var tabPane = new LayoutAnchorablePane(); 
paneGroup.Children.Add(tabPane); 
tabPane.Children.Add(new LayoutAnchorable { ContentId = "Validation", Title = "Validation" }); 
tabPane.Children.Add(new LayoutAnchorable { ContentId = "Search", Title = "Search" });