Hi I have this snippet
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void ToggleButton_Checked(object sender, RoutedEventArgs e)
{
switch ((sender as Button).Content.ToString())
{
case "UserControl 1":
AddItemToContainer(new UserControl1());
break;
case "UserControl 2":
AddItemToContainer(new UserControl2());
break;
case "UserControl 3":
AddItemToContainer(new UserControl3());
break;
default:
break;
}
}
void AddItemToContainer(UIElement _myElement)
{
Grid.SetColumn(_myElement, 1);
HostContainer.Children.Add(_myElement);
}
}
}
}
With this I can open a new userControl in myMainwindow
Let’s say something like adding child to myMainWinodw,Now I’m trying to click on a button from my userControl so I open another userControl that take the place of the first one
I explain:
I have the mainWindows it has 3 button first one to open the first UserControl the second one to open the second userControl and the third to open the last UserControl,imagine that I opened the first UserControl let’s call it UC1,
In the UC1 I have a button to open the second userControl (let’s call it UC2) I like that when I clik the button from the UC1 the UC2 is opened and take the place of the UC1 (of course the UC2 is still a child of myMainWinodw)
I have alredy try to call the AddItemToContainer methode from other methode but nothing is happened
Any suggestion please