How to restart a WPF application?

How to restart a WPF application from code? Windows Forms has Application.Restart, where for some reason Microsoft decided not to add this method to WPF.

I hate discomfort between WPF and WindowsForms! as:

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

What is wrong with this?

  window. Visible = false; 
+3
wpf
03 Sep '10 at 9:20
source share
1 answer

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 up the used space. This can make a big difference in the user interface.

Using the same enumeration for the visibility of a window class is IMO primarily a matter of storing a constant in the class library, but perhaps this also leads to some other more subtle differences.

Restart

If there is a possibility of a direct restart of the application, I do not know. Try using App.Current.Shutdown() to close the application and launch a new instance through System.Diagnostics.Process.Start() , where the path to the application can be taken from System.Reflection.Assembly.GetEntryAssembly() . `.

+3
03 Sep 2018-10-09T00:
source share



All Articles