I'm working on a desktop application. It has a dropdown menu
. When a menu item is clicked on the dropdown
a new tab
is opened if it's not opened before. There is a single tab
for a single dropdown menu item
. What i want to do is to open a window
, page
or user control
(i'm not sure which i should use) in seperate tab
s considering the work they will do.
My partial XAML
:
<dxd:DockLayoutManager DockItemClosing="DockLayoutManager_DockItemClosing_1">
<dxd:LayoutGroup>
<dxd:TabbedGroup Name="tabbedGroup">
</dxd:TabbedGroup>
</dxd:LayoutGroup>
</dxd:DockLayoutManager>
and partial CS
:
private void addPanel(string caption)
{
var contains = false;
var layoutPanel = new LayoutPanel() { Caption = caption };
BaseLayoutItem[] baseLayoutItem = tabbedGroup.GetItems();
foreach (var layoutItem in baseLayoutItem)
{
if (layoutItem.Caption.Equals(layoutPanel.Caption))
{
contains = true;
}
}
if (!contains)
{
tabbedGroup.Add(layoutPanel);
}
}
As i mentioned i want to append a window
, page
or user control
(i'm not sure which i should use) into every LayouPanel
opened seperately.
Ok it's as easy as:
layoutPanel.Content = new UserControl1();
And i got one more trick for dynamically creating the desired tab:
layoutPanel.Content = Activator.CreateInstance(Type.GetType(Constants.s_tabs[caption]));
I hope it won't cause any performance problems.