WPF C# Tutorial

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
public class EnterTheGrid : Window
{
    [STAThread]
    public static void Main()
    {
        Application app = new Application();
        app.Run(new EnterTheGrid());
    }
    public EnterTheGrid()
    {
        MinWidth = 300;
        SizeToContent = SizeToContent.WidthAndHeight;
        StackPanel stack = new StackPanel();
        Content = stack;
        Grid grid2 = new Grid();
        grid2.Margin = new Thickness(10);
        stack.Children.Add(grid2);
        grid2.ColumnDefinitions.Add(new ColumnDefinition());
        Button btn = new Button();
        btn.Content = "Submit";
        btn.HorizontalAlignment = HorizontalAlignment.Center;
        btn.IsDefault = true;
        btn.Click += delegate { Close(); };
        grid2.Children.Add(btn);    
        btn = new Button();
        btn.Content = "Cancel";
        btn.HorizontalAlignment = HorizontalAlignment.Center;
        btn.IsCancel = true;
        btn.Click += delegate { Close(); };
        grid2.Children.Add(btn);
        Grid.SetColumn(btn, 1);     
        (stack.Children[0] as Panel).Children[1].Focus();
    }
}