Hi,
I have a button in my Main window, on the click of this button the Main window should be reloaded. How to achieve this?
Please reply
Thanks Sharath
Hi,
I have a button in my Main window, on the click of this button the Main window should be reloaded. How to achieve this?
Please reply
Thanks Sharath
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
public Button button
{
get
{
return this.button1; //Expose the button.
}
}
}
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
this.MainWindow = new Window1(); //create the window
this.ShutdownMode = ShutdownMode.OnExplicitShutdown;
((Window1)MainWindow).button1.Click += new RoutedEventHandler(button1_Click); //add a handler to that button
MainWindow.Show();
}
void button1_Click(object sender, RoutedEventArgs e)
{
this.MainWindow.Close(); //Is disposed
MainWindow = new Window1(); //recreate
this.MainWindow.Show(); //reload
}
}