我正在尝试使用以下代码以编程方式在选项卡栏中创建两个窗格:
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 :(得分:1)
事实证明这比我想象的要容易。我所要做的就是将LayoutAnchorable
添加到同一个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" });