Most of the WPF examples out there start with too much Xaml - seems like it's just going to get in the way for now.
Norbert Eder's blog had the meat of this - I just stripped it down even more.
using System;
using System.Windows;
using System.Windows.Controls;
public class App : Application
{
[STAThread]
static void Main(string[] args)
{
Application app = new Application();
app.Run(new MainWindow());
}
}
public class MainWindow : Window
{
public MainWindow()
{
Button button1 = new Button();
button1.Content = "Bye";
button1.Click += new RoutedEventHandler(button1_Click);
this.Content = button1;
this.Title = "Hello world";
}
void button1_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown(0);
}
}
The project only needs a couple references – PresentationCore, PresentationFramework, System, and WindowsBase:
No comments:
Post a Comment