我正在使用功能区控件,并使用栏项目单击和Dock布局管理器,我正在调用选项卡,但无法在其中设置用户控件。
private void BarButtonItem_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) {
ActivateOrCreate("Company");
}
private void BarButtonItem_ItemClick_1(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) {
ActivateOrCreate("Branch");
}
private void ActivateOrCreate(string caption) {
LayoutPanel layoutPanel = DockTabbed.GetItems().OfType<LayoutPanel>().Where(x => String.Equals(x.Caption, caption)).FirstOrDefault();
if (layoutPanel == null) {
layoutPanel = new LayoutPanel() { Caption = caption };
layoutPanel.Content = new TextBlock() { Text = caption };
DockTabbed.DockController.Dock(layoutPanel, TabbedView, DevExpress.Xpf.Layout.Core.DockType.Fill);
}
DockTabbed.Activate(layoutPanel);
}
在此我要在布局面板中显示用户控件。
答案 0 :(得分:0)
Winform控件通常使用Controls.add方法添加和显示控件或用户控件! 像这样使用:
layoutPanel.Controlss.Add(new TextBlock() { Text = caption, Size=new Size(x,y),... };