Load Method
Collapse the table of content
Expand the table of content

XamlReader.Load Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Parses a well-formed XAML fragment and creates a corresponding Windows Phone object tree, and returns the root of the object tree.

Namespace:  System.Windows.Markup
Assembly:  System.Windows (in System.Windows.dll)

public static Object Load(
	string xaml


Type: System.String
A string that contains a valid XAML fragment.

Return Value

Type: System.Object
The root object of the Windows Phone object tree.

A "well-formed XAML fragment" must meet the following requirements:

  • The XAML content string must define a single root element.

  • The content string XAML must be well formed XML, as well as being parseable XAML.

  • The required root element must also specify a default XML namespace value. This is typically the Windows Phone namespace, xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation". This XML namespace is required explicitly in Windows Phone .

Note that these conditions report parsing exceptions but the message in the exception will specifically note the cause indicating a general format failure rather than a specific parsing failure against the vocabulary identified by the XML namespace.

Beyond being "well-formed", Load will also report failures that occur when the XAML is submitted to the parser.

Any objects with a Name or x:Name value in the input XAML will be considered to be within a discrete XAML namescope, once the returned object tree is added to the main object tree. This can influence your ability to find the object in scope with FindName.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft