Share via


How to: Add New Items to a WPF Project

This topic shows how to add new windows, pages, user controls, and resource dictionaries to your Windows Presentation Foundation (WPF) projects. For information on adding items which are not specific to WPF, see How to: Add New Project Items.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Working with Settings.

To create the project

To add a new Window class

  1. On the Project menu, select Add Window.

    The Add New Item dialog box appears.

  2. In the Name text box, name the class DemoWindow.xaml and click the Add button.

    DemoWindow.xaml is added to the project and opens in the designer. The code-behind file is also added to the project. It is named DemoWindow.xaml.cs or DemoWindow.xaml.vb, depending on the project's language.

To add a new Page class

  1. In Solution Explorer, select the DemoApplication project.

  2. On the Project menu, select Add Page.

    The Add New Item dialog box appears.

  3. In the Name text box, name the class DemoPage.xaml and click the Add button.

    DemoPage.xaml is added to the project and opens in the designer. The code-behind file is also added to the project. It is named DemoPage.xaml.cs or DemoPage.xaml.vb, depending on the project's language.

To add a new User Control class

  1. In Solution Explorer, right-click the DemoApplication project, point to Add, and then select User Control.

    The Add New Item dialog box appears.

  2. In the Name text box, name the class DemoControl.xaml and click the Add button.

  3. DemoControl.xaml is added to the project and opens in the designer. The code-behind file is also added to the project. It is named DemoControl.xaml.cs or DemoControl.xaml.vb, depending on the project's language.

To add a new Resource Dictionary

  1. In Solution Explorer, right-click the DemoApplication project, point to Add, and then select Resource Dictionary.

    The Add New Item dialog box appears.

  2. In the Name text box, name the dictionary Resources.xaml and click the Add button.

  3. Resources.xaml is added to the project and opens in the code editor.

    Note

    There is no visual designer for XAML resources.

See Also

Tasks

How to: Create a New WPF Application Project

How to: Create a WPF UserControl Library Project

How to: Add New Project Items

How to: Add Existing Items to a Project

How to: Create a C# WPF Application

Creating a Drawing Application by Using WPF

Other Resources

WPF Designer

Working with Controls in the WPF Designer