XamlServices.Load XamlServices.Load XamlServices.Load XamlServices.Load Method

Definition

Loads source for a XAML reader and writes its output as an object graph.

Overloads

Load(Stream) Load(Stream) Load(Stream)

Loads a Stream source for a XAML reader and writes its output as an object graph.

Load(TextReader) Load(TextReader) Load(TextReader)

Creates a XAML reader from a TextReader, and returns an object graph.

Load(String) Load(String) Load(String) Load(String)

Loads a Stream source for a XAML reader and returns an object graph.

Load(XamlReader) Load(XamlReader) Load(XamlReader)

Loads a specific XAML reader implementation and returns an object graph.

Load(XmlReader) Load(XmlReader) Load(XmlReader)

Loads a specific XML reader implementation and returns an object graph.

Load(Stream) Load(Stream) Load(Stream)

Loads a Stream source for a XAML reader and writes its output as an object graph.

public:
 static System::Object ^ Load(System::IO::Stream ^ stream);
public static object Load (System.IO.Stream stream);
static member Load : System.IO.Stream -> obj

Parameters

stream
Stream Stream Stream Stream

The stream to load as input.

Returns

The object graph that is written as output.

Exceptions

Remarks

Different signatures for the Load(Stream) method specify different types of input for the source XAML. The Load(Stream) internal implementation first creates an XmlReader by calling Create(Stream) and then creates a new instance of a specialized XamlReader that processes the input.

In order for the Load(Stream) call to successfully create an object graph, the following must be true:

  • The source is well-formed and valid XML.

  • The source is valid XAML at the language level.

  • The XAML types that are specified in the source XAML must resolve to backing types in the relevant XAML namespaces. For example, XAML types for WPF namespaces can resolve to a WPF XAML namespace as specified in the XAML; the assemblies for WPF must be included in the project or available in the run time; and so on.

Important

XamlServices is not the recommended XAML reading or XAML writing API set if you are processing Windows Presentation Foundation (WPF) types, or types based on WPF. For WPF usage, use System.Windows.Markup.XamlReader for reading or loading XAML; and System.Windows.Markup.XamlWriter for writing back XAML. These classes use System.Xaml APIs internally in their implementation; however, they also provide support for WPF-specific concepts that influence the nature of XAML reading and writing, such as optimizations for dependency properties.

Load(TextReader) Load(TextReader) Load(TextReader)

Creates a XAML reader from a TextReader, and returns an object graph.

public:
 static System::Object ^ Load(System::IO::TextReader ^ textReader);
public static object Load (System.IO.TextReader textReader);
static member Load : System.IO.TextReader -> obj

Parameters

textReader
TextReader TextReader TextReader TextReader

The TextReader to use as the basis for the created XmlReader.

Returns

The object graph that is returned.

Exceptions

Remarks

In order to return the object graph, the textReader input should be constructed by using its relevant input. For example, it should pass a StringReader that is constructed by using a valid XAML-as-string input for the StringReader(String) constructor.

Load(String) Load(String) Load(String) Load(String)

Loads a Stream source for a XAML reader and returns an object graph.

public:
 static System::Object ^ Load(System::String ^ fileName);
public static object Load (string fileName);
static member Load : string -> obj
Public Shared Function Load (fileName As String) As Object

Parameters

fileName
String String String String

The file name to load and use as source.

Returns

The object graph that is returned.

Exceptions

Remarks

Different signatures for the Load method specify different types of input for the source XAML. The Load internal implementation first creates an XmlReader by calling Create(String) and then creates a new instance of a specialized XamlReader that processes the input.

In order for the Load(String) call to successfully create an object graph, the following must be true:

  • The source is well-formed and valid XML.

  • The source is valid XAML at the language level.

  • The XAML types that are specified in the source XAML must resolve to backing types in the relevant XAML namespaces. For example, XAML types for WPF namespaces can resolve to a WPF XAML namespace as specified in the XAML; the assemblies for WPF must be included in the project or be available in the run time; and so on.

Load(XamlReader) Load(XamlReader) Load(XamlReader)

Loads a specific XAML reader implementation and returns an object graph.

public:
 static System::Object ^ Load(System::Xaml::XamlReader ^ xamlReader);
public static object Load (System.Xaml.XamlReader xamlReader);
static member Load : System.Xaml.XamlReader -> obj

Parameters

xamlReader
XamlReader XamlReader XamlReader XamlReader

The XAML reader implementation to use as the reader for this Load operation.

Returns

The object graph that is returned.

Exceptions

Remarks

You should typically use this signature only in the following cases:

  • You defined your own implementation of a XamlReader.

  • You specified settings for a XamlReader that differ from the default settings.

Load(XmlReader) Load(XmlReader) Load(XmlReader)

Loads a specific XML reader implementation and returns an object graph.

public:
 static System::Object ^ Load(System::Xml::XmlReader ^ xmlReader);
public static object Load (System.Xml.XmlReader xmlReader);
static member Load : System.Xml.XmlReader -> obj

Parameters

xmlReader
XmlReader XmlReader XmlReader XmlReader

The XmlReader implementation to use as the reader for this Load operation.

Returns

The output object graph.

Exceptions

Remarks

You should typically use this signature only if you defined your own implementation of a XmlReader.

Applies to