Share via


Walkthrough: Interpreting XAML Errors in the WPF Designer

This topic shows how to get Help when errors occur while loading Extensible Application Markup Language (XAML) in the Windows Presentation Foundation (WPF) Designer for Visual Studio. 

Tasks explained in this walkthrough include:

  • Creating the project.

  • Generating a XAML loader error.

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 Visual Studio Settings.

Prerequisites

You need the following components to complete this walkthrough:

  • Visual Studio 2008.

Creating the Project

The first step is to create the project for the application.

To create the project

To generate a XAML error

  1. In XAML view, generate an error by adding a space after the open angle bracket of the <Grid> tag. The XAML should look like the following.

    <Window x:Class="DemoApplication.Window1"
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <!-- The following line has error XAML0302. -->
        < Grid>
    
        </Grid>
    </Window>
    

    An error appears in the Error List window: "Invalid white space. White space cannot follow the open angle bracket character '<' in an element tag." When you switch to Design view, the following message appears. "The document contains errors that must be fixed before the designer can be loaded. Reload the designer after you have fixed the errors."

  2. Double-click the error in the Error List. "

    The Grid element's opening tag is highlighted in XAML view.

  3. Press F1 to open Help.

    The Help topic for error XAML0302 opens.

See Also

Tasks

Walkthrough: Editing XAML in the WPF Designer

Concepts

Split View: Viewing the WPF Design Surface and XAML at the Same Time

XAML Parser Architecture

XAML Overview

Reference

Invalid white space

Error List Window

Other Resources

Error Message Reference for the WPF Designer

WPF Designer

Using Resources