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.

To create and test a WPF project

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

    Cc296398.f60e8b59-50de-4da1-9ba8-722dc5394d9d(en-us,Expression.10).png

    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.

    Cc296398.6077fdd4-d9ee-4372-9324-4e417771b3d6(en-us,Expression.10).png

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

    Cc296398.8fbbbb21-be83-4cf6-903b-3a49f00c9860(en-us,Expression.10).png

    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.

    Cc296398.4da470fa-7261-468c-828a-6694f55af53b(en-us,Expression.10).png

    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

See also

Concepts

Undo or redo an action

Add, link to, or remove an existing item from a project

Change the active document

Insert an item into the active document

Insert an image, audio, or video file into the active document