XamlReader.LoadAsync XamlReader.LoadAsync XamlReader.LoadAsync XamlReader.LoadAsync Method

Definition

Reads XAML markup and returns an object that corresponds to the root of the specified markup.

Overloads

LoadAsync(Stream) LoadAsync(Stream) LoadAsync(Stream)

Reads the XAML input in the specified Stream and returns the root of the corresponding object tree.

LoadAsync(XmlReader) LoadAsync(XmlReader) LoadAsync(XmlReader) LoadAsync(XmlReader)

Reads the XAML input in the specified XmlReader and returns the root of the corresponding object tree.

LoadAsync(Stream, ParserContext) LoadAsync(Stream, ParserContext) LoadAsync(Stream, ParserContext)

Reads the XAML input in the specified Stream and returns the root of the corresponding object tree.

LoadAsync(Stream) LoadAsync(Stream) LoadAsync(Stream)

Reads the XAML input in the specified Stream and returns the root of the corresponding object tree.

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

Parameters

stream
Stream Stream Stream Stream

The stream containing the XAML input to load.

Returns

The object that is the root of the created object tree.

Exceptions

Remarks

An asynchronous XAML load operation will initially return an object that is purely the root object. Asynchronously, XAML parsing then continues, and any child objects are filled in under the root. This is in contrast to the typical WPF XAML processing behavior and its interaction with WPF concepts of object lifetime. In the typical (non-async) interaction, all properties of an object including all child collections are filled before returning an element and reporting it as loaded. That behavior equates to a bottom-up methodology for creating the tree where the root object is the last object to become available.

You typically would assign the returned object to some location in your WPF application's object tree, with the knowledge that content might still be filling in and might cause incremental layout updates if the entire content is exposed as part of the UI. For this reason it is typical to isolate or virtualize any asynchronously loaded objects from XAML, and to use application-specific logic or application state to notify when LoadCompleted is handled.

In order for LoadAsync to load XAML input asynchronously, the root element in the XAML input must contain the attribute and value x:SynchronousMode="Async". The value is treated as case sensitive. If the XAML input root does not contain x:SynchronousMode="Async", no exception is thrown, and the call is processed as a synchronous load (see Load(Stream)).

Only one asynchronous load operation per instance of the XamlReader class can be performed at a time. If more than one asynchronous operation is attempted on the same instance of the XamlReader class an InvalidOperationException is thrown.

See also

LoadAsync(XmlReader) LoadAsync(XmlReader) LoadAsync(XmlReader) LoadAsync(XmlReader)

Reads the XAML input in the specified XmlReader and returns the root of the corresponding object tree.

public:
 System::Object ^ LoadAsync(System::Xml::XmlReader ^ reader);
public object LoadAsync (System.Xml.XmlReader reader);
member this.LoadAsync : System.Xml.XmlReader -> obj
Public Function LoadAsync (reader As XmlReader) As Object

Parameters

reader
XmlReader XmlReader XmlReader XmlReader

An existing XmlReader that has already loaded/read the XAML input.

Returns

The root of the created object tree.

Exceptions

Remarks

An asynchronous XAML load operation will initially return an object that is purely the root object. Asynchronously, XAML parsing then continues, and any child objects are filled in under the root. This is in contrast to the typical WPF XAML processing behavior and its interaction with WPF concepts of object lifetime. In the typical (non-async) interaction, all properties of an object including all child collections are filled before returning an element and reporting it as loaded. That behavior equates to a bottom-up methodology for creating the tree where the root object is the last object to become available.

You typically would assign the returned object from LoadAsync to some location in your application's object tree, with the knowledge that content might still be filling in and might cause incremental layout updates if the entire content is exposed as part of the UI. For this reason it is typical to isolate or virtualize any asynchronously loaded objects from XAML, and to use application-specific logic or application state to notify when LoadCompleted is handled.

In order for LoadAsync to load XAML input asynchronously, the root element in the XAML markup must contain the attribute and value x:SynchronousMode="Async". The value is treated as case sensitive. If the XAML markup root does not contain x:SynchronousMode="Async", no exception is thrown, and the call is instead processed as a synchronous load (see Load(XmlReader)).

Only one asynchronous load operation per instance of the XamlReader class can be performed at a time. If more than one asynchronous operation is attempted on the same instance of the XamlReader class an InvalidOperationException is thrown.

See also

LoadAsync(Stream, ParserContext) LoadAsync(Stream, ParserContext) LoadAsync(Stream, ParserContext)

Reads the XAML input in the specified Stream and returns the root of the corresponding object tree.

public:
 System::Object ^ LoadAsync(System::IO::Stream ^ stream, System::Windows::Markup::ParserContext ^ parserContext);
public object LoadAsync (System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext);
member this.LoadAsync : System.IO.Stream * System.Windows.Markup.ParserContext -> obj

Parameters

stream
Stream Stream Stream Stream

A stream containing the XAML input to load.

parserContext
ParserContext ParserContext ParserContext ParserContext

Context information used by the parser.

Returns

The root of the created object tree.

Exceptions

Remarks

An asynchronous XAML load operation will initially return an object that is purely the root object. Asynchronously, XAML parsing then continues, and any child objects are filled in under the root. This is in contrast to the typical WPF XAML processing behavior and its interaction with WPF concepts of object lifetime. In the typical (non-async) interaction, all properties of an object including all child collections are filled before returning an element and reporting it as loaded. That behavior equates to a bottom-up methodology for creating the tree where the root object is the last object to become available.

You typically would assign the returned object to some location in your application's object tree, with the knowledge that content might still be filling in and might cause incremental layout updates if the entire content is exposed as part of the UI. For this reason it is typical to isolate or virtualize any asynchronously loaded objects from XAML, and to use application-specific logic or application state to notify when LoadCompleted is handled.

In order for LoadAsync to load markup asynchronously, the root element in the XAML markup must contain the attribute and value x:SynchronousMode="Async". The value is treated as case sensitive. If the XAML markup root does not contain x:SynchronousMode="Async", no exception is thrown, and the call is processed as a synchronous load (see Load(Stream, ParserContext)).

Only one asynchronous load operation per instance of the XamlReader class can be performed at a time. If more than one asynchronous operation is attempted on the same instance of the XamlReader class an InvalidOperationException is thrown.

See also

Applies to