-1

I am using WPF application and I want to display popup and when I Click on OK button then Popup should close and it should display UserControl. Hope my question is clear to all.

Avinash
  • 9
  • 1

1 Answers1

0

if you want to change userControl by code

Panel myPanel = new Panel();    
LoginPage ctlLoginPage = new LoginPage();
HomePage ctlHomePage = new HomePage();

//add the loginpage to the panel first
myPanel.Controls.Add(ctlLoginPage);

...do stuff...

//remove whatever control is currently in the Panel
myPanel.Controls.Clear();
//add the other control, the HomePage control instead now
myPanel.Controls.Add(ctlHomePage);
Yiao SUN
  • 908
  • 1
  • 8
  • 26
  • Thanks for your reply. I have wrote the code like above you have mentioned. When First time popup is opened and I press OK button then it display respective usercontrol.but when second time Popup is opened then usercontrol didn't display. I am using window form to display the popup. by using and my code is : PopupWindow PW = new PopupWindow(); PW.SetParent(this); PW.ShowDialog(); – Avinash Feb 16 '18 at 10:56
  • @Avinash maybe you should add PW.Dispose(); at the end of your code – Yiao SUN Feb 16 '18 at 11:05
  • i am using PW.Dispose(); but it is showing error : does not contain a definition for 'Dispose' and no extension method 'Dispose' accepting a first argument of type – Avinash Feb 16 '18 at 11:20