简体   繁体   English

按下按钮将WPF窗口重置为其原始状态(启动)

[英]Reset WPF window to its original state(startup) with a press of a button

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. 按下“新建”按钮后,我想将wpf重置为其首次启动时的原始状态。 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? 我如何在WPF中实现这一目标?

Window win = new Window();

win.ShowDialog();

Try this by replacing your window name to 'Window'. 通过将窗口名称替换为“ Window”来尝试此操作。 Do this inside your button click event. 在您的按钮单击事件中执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM