如何在按钮上更改用户控制窗口 [英] how to change user control windows on botton click
本文介绍了如何在按钮上更改用户控制窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个主窗口。我有2个bottons。我需要做的是,当我按下按钮1我想在主窗口中显示一个用户控制窗口,当我按下按钮2,然后另一个用户控制窗口应该显示在同一个地方,第一个要冻结。我想在c#,wpf中做。所以请任何人帮助我。
i have a main window.In that i have 2 bottons.And what i need to do is that when i press button 1 i want to show a usercontrol window in the main window and when i press button 2 ,then another user control window should be displayed in same place and the first one to be freezed.i wanna do it in c#,wpf.So please anyone help me.
推荐答案
这个链接对你有帮助..
http://stackoverflow.com/questions / 302839 / wpf-user-control-parent [ ^ ]
以及这一个..
http://stackoverflow.com/questions/4577635/adding-user-control-page-to-windows-xaml-programatically-in-wpf [ ^ ]
This link would be helpful for you..
http://stackoverflow.com/questions/302839/wpf-user-control-parent[^]
and also this one..
http://stackoverflow.com/questions/4577635/adding-user-control-page-to-windows-xaml-programatically-in-wpf[^]
1 - 在名为mainPanel的窗口中添加一个包裹面板
2 - 添加按钮1单击事件
3添加按钮2单击事件
4-write uc 1
5-write uc 2
6-on button 1点击后面的代码
mainPanel.Children.Clear( );
mainPanel.Children.Add(uc1);
7-on按钮2点击后面的代码
mainPanel.Children.Clear() ;
mainPanel.Children.Add(uc2);
这样做。
1-add a wrap panel to the window called mainPanel
2-add button 1 click event
3-add button 2 click event
4-write uc 1
5-write uc 2
6-on button 1 click code behind
mainPanel.Children.Clear();
mainPanel.Children.Add (uc1);
7-on button 2 click code behind
mainPanel.Children.Clear();
mainPanel.Children.Add (uc2);
this will do it.
我写的步骤应该有效,进行此更改:在初始化加载/添加到主面板之后,2个用户控件显示1并隐藏另一个,然后点击事件应该可以正常工作。
The steps I wrote should work, make this change: after the Initialize load/add to the main Panel the 2 User Controls show 1 and hide the other, then the click events should work as you want.
这篇关于如何在按钮上更改用户控制窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文