#184 – Creating a WPF Application Using Visual Studio

You can create a basic WPF application using Visual Studio 2010.  Open Visual Studio and select File | New | Project.  Then select WPF Application as the template to use for creating the project.

This will generate a project with the project structure shown below.

The project contains:

  • An App class, deriving from System.Windows.Application
    • Has Main() method, defined in automatically generated App.g.i.cs file
    • Empty App.xaml file, defining main <Application> element
    • Empty App.xaml.cs file with partial class for App
  • A MainWindow class, deriving from System.Windows.Window
    • InitializeComponent() method, defined in auto-generated MainWindow.g.i.cs file, which reconstitutes object from XAML file
    • MainWindow.xaml file, containing <Window> object and a child <Grid>
    • Empty MainWindow.xaml.cs file with partial class for MainWindow