WPF | Sidebar , Multi Window Navigation
HTML-код
- Опубликовано: 23 июл 2022
- How to Create a sidebar in WPF?
How to Create a Navigation bar in WPF?
How to host multiple windows in Mainwindow?
How to click a button from child window?
How to navigate multiple windows?
#wpf
#sidebar
#navigation bar
#multiple window navigation
Thanks for the simple explanation and relatively short video! This is what I was looking for!
pleased to hear that! thank you.,,
This is a good example of calling UserControls from the main window. If you had more RadioButtons, you can shorten things by using the same Checked event for all the RadioButtons, then use a Switch statement. Like this:
private void rbtn_Checked(object sender, RoutedEventArgs e)
{
string senderName = (sender as RadioButton).Name;
switch (senderName)
{
case "rbtn1": CC.Content = new UserControl1(); break;
case "rbtn2": CC.Content = new UserControl3(); break;
case "rbtn3": CC.Content = new UserControl3(); break;
default:
break;
}
}
For more complicated cases you can also use Reflection to determine the UserControl name from the RadioButton name, then instantiate and call the correct UserControl. This is done like this:
private void rbtnWitnReflection_Checked(object sender, RoutedEventArgs e)
{
string senderName = (sender as RadioButton).Name;
string assemName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
string ucFullName = assemName + "." + senderName.Replace("rbtn", "UserControl");
object uc = Activator.CreateInstance(Type.GetType(ucFullName));
CC.Content = uc;
}
Certainly..Thanks for sharing!
Thanks very much. Just what I wanted to get my project started
Bro, you just helped me so much, i can't thank you enough
I tried to make something “cool”, but explanations were too complicated. This video is as simple simple as cool) Everything ingenious is simple) Thank you so much)
you're welcome!
thanks for the appreciation..
You just made my day!! Thank you so much!
happy to help
Nice mm
Thanks mm
Thank you for the explanation
Can we give another user control inside main user control for submenu so that we can have navigation for submenu also
thanks much appreciated
welcome.. tnx for the comment
How about when using the MVVM pattern?
how to join UserControl2 and UserControl3 under a category and continue using radio buttons
Explain please
CC return null what to do
Thank you....