BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Windows Presentation Foundation
.NET 4.0+

Creating a WPF Project in Visual Studio

The third part of the Windows Presentation Foundation Fundamentals tutorial explains how a new WPF Application project can be created in Visual Studio and describes the basic Visual Studio windows used to edit the XAML design and code.

Solution Explorer

The solution explorer shows all of the projects in the solution and all of the files that are part of those projects. For WPF projects the files include XAML and code-behind, as well as other code and designer files. The default WPF application project includes several files. MainWindow.xaml and MainWindow.xaml.cs hold the design and code-behind for the default window. App.xaml is a special file that is used to centralise resources such as styles. App.config holds text-based configuration information for your software, which can be edited directly or built from application settings. To open a file for editing you can double-click it.

If you cannot see the solution explorer, open the View menu and select the Solution Explorer option.

Properties Window

The properties window allows you to view and configure the properties of the currently selected item in the designer, or the item that the text cursor, or caret, is located within in the XAML editor. It shows a list of all of the properties of the item and their current values. Most of those properties can be modified by entering new values or selecting them, although some complex properties must be set in the XAML. The method of selection varies according to the property type. For example, colour properties can be adjusted by selecting the colour graphically.

The list of properties can be sorted alphabetically or organised into categories by selecting the appropriate option. You can also search for a properly by entering part of its name into the search box. Try typing "Back" into the search box. You should see the Background property. This shows the default colour for the button's background. As you change the colour you will see the new value reflected in the window designer and the XAML editor.

If you cannot see the properties window, choose the Properties Window option from the View menu.

What's Next?

There are many other ways to use the windows described above and many other windows to explore that are useful for WPF application development. The information above describes the basics that we'll use throughout the rest of the tutorial.

In the next article in the series we'll begin to look at the layout controls that WPF provides. These allow you to organise other controls in windows and dialog boxes. We'll then look at the various content controls that allow you to build user interfaces with XAML. We'll concentrate on the XAML code but many of the tasks described can also be achieved using the window designer and properties window.

10 February 2013