using System;
using System.Windows;
using System.Windows.Controls;
namespace SimpleWPFApp
{
class MyWPFApp : Application
{
[STAThread]
static void Main(string[] args)
{
MyWPFApp app = new MyWPFApp();
app.Startup += new StartupEventHandler(AppStartUp);
app.Exit += new ExitEventHandler(AppExit);
app.Run();
}
static void AppExit(object sender, ExitEventArgs e)
{
MessageBox.Show("App has exited");
}
static void AppStartUp(object sender, StartupEventArgs e)
{
MainWindow wnd = new MainWindow("My better WPF App!", 200, 300);
}
}
class MainWindow : Window
{
private Button btnExitApp = new Button();
public MainWindow(string windowTitle, int height, int width)
{
btnExitApp.Click += new RoutedEventHandler(btnExitApp_Clicked);
btnExitApp.Content = "Exit Application";
btnExitApp.Height = 25;
btnExitApp.Width = 100;
this.AddChild(btnExitApp);
this.Title = windowTitle;
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Height = height;
this.Width = width;
this.Show();
}
private void btnExitApp_Clicked(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}
/*
# build.rsp
#
/target:winexe
/out:SimpleWPFApp.exe
/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll"
/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll"
/r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll"
*.cs
*/