Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.
Posted
Updated 22-Jul-13 1:08am
v2
Comments
prapaug 22-Jul-13 7:19am    
ANYONE PLEASE HELP ME FAST..ITS URGENT
[no name] 23-Jul-13 11:42am    
Not it's not urgent at all. And there is no need to scream at people.
Jean A Brandelero 22-Jul-13 7:23am    
button1_click:

main.Enabled = false;
or
main.Visible = false;

form1 f = new form1();
f.Size = main.Size;
f.Location = main.Location;
f.ShowDialog();
ridoy 22-Jul-13 7:58am    
Xinapstrink did a good job within few lines:)
Pheonyx 22-Jul-13 7:59am    
What have you tried so far?
Are you looking to use a MVVM approach or just a standard code behind handling events approach?

 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
prapaug 23-Jul-13 1:08am    
It's not working.Anyone have any other answers???
Help me fast.
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.
 
Share this answer
 
Comments
prapaug 23-Jul-13 1:52am    
can you pls write the entire cs code and xaml?
prapaug,

if you said that it does not work, post the code to review.

cocis48
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900