I have a 'New' Button which creates a new file. On the press of 'New' button i want to reset a wpf to its original state like it was started first time. All the control should be in there start position.All the variable should be reinitialized. Consider it like a closing an application and again restarting it but, i don't want close the application. How can i achieve this in WPF?
Asked
Active
Viewed 3,080 times
1
-
You can [restart application](http://stackoverflow.com/q/4773632/1997232) indeed, but more correct way is to provide mechanism for this. Either ViewModel (MVVM?) does this (there could be a method which reset binding sources values somehow) or you can simply recreate window. – Sinatr Jun 17 '15 at 09:14
-
Thanks for replay Sinatr. I will manually reset all controls as it's sound easy for few controls. – Bhavesh Jadav Jun 17 '15 at 09:43
1 Answers
0
Window win = new Window();
win.ShowDialog();
Try this by replacing your window name to 'Window'. Do this inside your button click event.

Chameena Hiruni
- 52
- 11