C#WPF显示另一个UserControl的Usercontrol [英] C# WPF Display Usercontrol from another UserControl
问题描述
我有3个xaml文件,如下所述:
1 。 MainWindow.xaml
2. UserControl1.xaml
3. UserControl2.xaml
In UserControl1.xaml有一个按钮。
在主窗口中我在 ContentControl 中显示用户控件。显示 UserControl1.xaml 后,如果我点击按钮 UserControl1.xaml 应该是不可见的,并且应该显示 UserControl2.xaml 相同的 ContentControl 。
所以我有点困惑怎么做?
简而言之,我的查询是:
显示用户控件来自另一个用户控件的按钮单击主窗口
Hi,
I have 3 xaml file as below mentioned:
1. MainWindow.xaml
2. UserControl1.xaml
3. UserControl2.xaml
In UserControl1.xaml one button is there.
In Main Window I am displaying the user control in ContentControl. Once UserControl1.xaml is displayed and after that If I click on the button UserControl1.xaml should be invisible and UserControl2.xaml should be dislayed in the same ContentControl.
So I am little bit confused how to do this?
In short my query is :
Showing User control from another user control's button click in Main Window
推荐答案
private void Press_Click(object sender,RoutedEventArgs e)
{
window2 win2 = new window2();
win2.Show();
this.Close();
}
private void Press1_Click(对象发送者,RoutedEventArgs) e)
{
window3 win3 = new window3();
win3.Show();
this .Close();
}
private void Press_Click(object sender, RoutedEventArgs e)
{
window2 win2= new window2();
win2.Show();
this.Close();
}
private void Press1_Click(object sender, RoutedEventArgs e)
{
window3 win3= new window3();
win3.Show();
this.Close();
}
这篇关于C#WPF显示另一个UserControl的Usercontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!