I am new to WPF, my problem is that I have a top menu as UserControl
added in the main window and the main window is split into three columns: in the right most column I have a DockPanel
, now my problem is that I don't know how to add another control in that right column when I click on the top menu item.
Some code, to illustrate my attempt:
public partial class TopMenu : UserControl
{
private void menuItem_Click(object sender, RoutedEventArgs e)
{
SecondControl ctrl = new SecondControl();
Window1 winMain = new Window1();
winMain.dp3.Children.Add(ctrl ); // dp3 is the dock panel in the right column of
}
}
Now, what should I do to display that control on window1
?