Delete the existing App.xaml file and write a new class file(lets call it StartUp.cs) that looks like below:
public class StartUp : Application
{
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static void Main()
{
StartUp app = new StartUp();
app.InitializeComponent();
app.Run();
}
public void InitializeComponent()
{
this.StartupUri = new Uri("MainWindow.xaml", System.UriKind.Relative);
}
}
Note that this class inherits System.Windows.Application
public class StartUp : Application
{
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static void Main()
{
StartUp app = new StartUp();
app.InitializeComponent();
app.Run();
}
public void InitializeComponent()
{
this.StartupUri = new Uri("MainWindow.xaml", System.UriKind.Relative);
}
}
Note that this class inherits System.Windows.Application
thank's of lot.....
ReplyDeletevery useful code.....
excellent dude.. this is exactly what im looking for.
ReplyDeleteIt can also simplified like below
ReplyDeletepublic class StartUp : System.Windows.Application
{
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static void Main()
{
new StartUp { StartupUri = new Uri("MainWindow.xaml", System.UriKind.Relative) }.Run();
}
}