Create and test a WPF project

This page applies to WPF projects only

A Windows Presentation Foundation (WPF) project will build a Microsoft Windows application (.exe) that you can run on your Windows desktop. Microsoft Expression Blend 2 makes it easy to design the user interface for your application.

  1. In Expression Blend, click New Project on the File menu.


    The New Project dialog appears.

  2. Under Select a project type, click WPF Application (.exe). The other fields display default values for the project name, location, programming language for the code-behind files, and the target version of the Microsoft .NET Framework. You can leave those fields as they are and click OK.

    A new WPF project is created and the startup page, Window1.xaml, opens for editing.

  3. Click the Project panel to view the files that were created for your project.

    If you are a graphic designer who is working with a programmer to produce a WPF application, both of you can work on the project at the same time; you would design the user interface by working with the markup files (.xaml), and the programmer would work with the code-behind files (.xaml.cs or .xaml.vb), possibly using Microsoft Visual Studio 2008.

  4. Make sure the Design view is visible by clicking either the Design or Split tab on the side of the artboard. This will enable you to select items in the Toolbox to draw them on the artboard.

  5. From the Toolbox, select the Rectangle Cc296398.81ffc148-cf5c-4faf-bd3f-f38d3073a12c(en-us,Expression.10).png tool.


    Click and drag your mouse on the artboard to draw a rectangle. If you want to constrain the aspect ratio in order to make a square, hold the SHIFT key while you drag.


    A new Rectangle object is added as a child object under the LayoutRoot object.

    The SHIFT and ALT keys modify most artboard actions when creating or modifying objects. SHIFT typically constrains the aspect ratio or rotation angle, and ALT typically maintains the center point. Selecting tools and controls from the Toolbox to draw them on the artboard is the most common way to add objects to your application. New objects are added as children of the active object (identified by a yellow bounding outline).

  6. Click Save All on the File menu to save your project to disk. Save early, save often.

  7. To build and run your application, click Test Solution on the Project menu (or press F5).

    If the test build is successful, your project will automatically open in an application window. If the test build is unsuccessful, you can view the build errors in the Results panel.

Next steps

Community Additions