Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is there a way to make a reset button that restarts my program from the beginning.

I used a button with the commands that is equal to Window_Loaded but I have converted some labels to int32 and if I reuse them, the program shuts down completely. I used label4.Content = string.Empty;
Posted
Updated 6-Dec-09 9:52am
v3

Oh, I see you are using WPF. In that case, you can use the following code to restart your application on a button click:
C#
// This will go in the event handler for your button click.
System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
Application.Current.Shutdown();

I found the above code here and tried it out myself... it works.
 
Share this answer
 
Comments
suman0713 11-Jan-12 7:28am    
Is there any way to restart or reload wpf browser application ?
In the click event handler for your button, use the following code:
C#
Application.Restart();
 
Share this answer
 
Comments
michle2408 18-Apr-13 12:14pm    
Hi!,

I am not getting "Application" instance in my application. Application.Restart means myCurrentWindowRestart(0? or what?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900