2015-11-16 45 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" });