XamlServices.Load Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Loads source for a XAML reader and writes its output as an object graph.
Overloads
Load(Stream) |
Loads a Stream source for a XAML reader and writes its output as an object graph. |
Load(TextReader) |
Creates a XAML reader from a TextReader, and returns an object graph. |
Load(String) |
Loads a Stream source for a XAML reader and returns an object graph. |
Load(XamlReader) |
Loads a specific XAML reader implementation and returns an object graph. |
Load(XmlReader) |
Loads a specific XML reader implementation and returns an object graph. |
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
Public Shared Function Load (stream As Stream) As Object
Parameters
- stream
- Stream
The stream to load as input.
Returns
The object graph that is written as output.
Exceptions
stream
is null
.
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.
Applies to
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
Public Shared Function Load (textReader As TextReader) As Object
Parameters
- textReader
- TextReader
The TextReader to use as the basis for the created XmlReader.
Returns
The object graph that is returned.
Exceptions
textReader
is null
.
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.
Applies to
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
The file name to load and use as source.
Returns
The object graph that is returned.
Exceptions
fileName
input is null
.
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.
Applies to
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
Public Shared Function Load (xamlReader As XamlReader) As Object
Parameters
- xamlReader
- XamlReader
The XAML reader implementation to use as the reader for this Load
operation.
Returns
The object graph that is returned.
Exceptions
xamlReader
input is null
.
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.
Applies to
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
Public Shared Function Load (xmlReader As XmlReader) As Object
Parameters
Returns
The output object graph.
Exceptions
xamlReader
input is null
.
Remarks
You should typically use this signature only if you defined your own implementation of a XmlReader.