开发者

How can I restart WPF application?

开发者 https://www.devze.com 2023-01-14 02:21 出处:网络
How can I restart WPF application from code? in Windows Forms there is Application.Restart, where for whatever reason Microsoft decided not to add this method in WPF.

How can I restart WPF application from code? in Windows Forms there is Application.Restart, where for whatever reason Microsoft decided not to add this method in WPF.

I hate the discompatability between WPF and WindowsForms! like:

            window.Visibility = System.Windows.Visibility.Hidden;

What's wrong with that?

           开发者_开发问答 window. Visible = false;


Visibility

For controls and panels, there is a huge difference between Visibility.Collapsed and Visiblity.Hidden. Hidden reserves the space of the invisible element, Collapse frees the used space. This can make a big difference in an UI.

Using the same enumeration for the visibility of the window-class is IMO first of all a question of holding a constancy in the class-library, but may be it makes also some other finer differences.

Restart

If there is a possibility to directly restart the app, I don't know. What you can try is to use App.Current.Shutdown() to close the app and start a new instance through System.Diagnostics.Process.Start() where the path to the app can be taken from System.Reflection.Assembly.GetEntryAssembly(). `.

0

精彩评论

暂无评论...
验证码 换一张
取 消