This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge
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

Examples

The following example saves a Button into a MemoryStream using the XamlWriter class. The stream is then loaded back into a Button using the static Load method on the XamlReader class.

// Create the Button. Button originalButton = new Button(); originalButton.Height = 50; originalButton.Width = 100; originalButton.Background = Brushes.AliceBlue; originalButton.Content = "Click Me"; // Save the Button to a string. string savedButton = XamlWriter.Save(originalButton); // Load the button StringReader stringReader = new StringReader(savedButton); XmlReader xmlReader = XmlReader.Create(stringReader); Button readerLoadButton = (Button)XamlReader.Load(xmlReader); ' Create the Button. Dim originalButton As New Button() originalButton.Height = 50 originalButton.Width = 100 originalButton.Background = Brushes.AliceBlue originalButton.Content = "Click Me" ' Save the Button to a string. Dim savedButton As String = XamlWriter.Save(originalButton) ' Load the button Dim stringReader As New StringReader(savedButton) Dim xmlReader As XmlReader = XmlReader.Create(stringReader) Dim readerLoadButton As Button = CType(XamlReader.Load(xmlReader), Button)
public:
 static System::Object ^ Load(System::Xaml::XamlReader ^ reader);
public static object Load (System.Xaml.XamlReader reader);
static member Load : System.Xaml.XamlReader -> obj
Public Shared Function Load (reader As XamlReader) As Object

Parameters

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

Parameters

Examples

The following example converts a Button into a string using the XamlWriter class. The string is then loaded back into a Button using the static Load method on the XamlReader class.

// Create the Button. Button originalButton = new Button(); originalButton.Height = 50; originalButton.Width = 100; originalButton.Background = Brushes.AliceBlue; originalButton.Content = "Click Me"; // Save the Button to a string. string savedButton = XamlWriter.Save(originalButton); // Load the button StringReader stringReader = new StringReader(savedButton); XmlReader xmlReader = XmlReader.Create(stringReader); Button readerLoadButton = (Button)XamlReader.Load(xmlReader); ' Create the Button. Dim originalButton As New Button() originalButton.Height = 50 originalButton.Width = 100 originalButton.Background = Brushes.AliceBlue originalButton.Content = "Click Me" ' Save the Button to a string. Dim savedButton As String = XamlWriter.Save(originalButton) ' Load the button Dim stringReader As New StringReader(savedButton) Dim xmlReader As XmlReader = XmlReader.Create(stringReader) Dim readerLoadButton As Button = CType(XamlReader.Load(xmlReader), Button)
public:
 static System::Object ^ Load(System::IO::Stream ^ stream, bool useRestrictiveXamlReader);
public static object Load (System.IO.Stream stream, bool useRestrictiveXamlReader);
static member Load : System.IO.Stream * bool -> obj
Public Shared Function Load (stream As Stream, useRestrictiveXamlReader As Boolean) As Object

Parameters

public:
 static System::Object ^ Load(System::IO::Stream ^ stream, System::Windows::Markup::ParserContext ^ parserContext);
public static object Load (System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext);
static member Load : System.IO.Stream * System.Windows.Markup.ParserContext -> obj
Public Shared Function Load (stream As Stream, parserContext As ParserContext) As Object

Parameters

public:
 static System::Object ^ Load(System::Xml::XmlReader ^ reader, bool useRestrictiveXamlReader);
public static object Load (System.Xml.XmlReader reader, bool useRestrictiveXamlReader);
static member Load : System.Xml.XmlReader * bool -> obj
Public Shared Function Load (reader As XmlReader, useRestrictiveXamlReader As Boolean) As Object

Parameters

public:
 static System::Object ^ Load(System::IO::Stream ^ stream, System::Windows::Markup::ParserContext ^ parserContext, bool useRestrictiveXamlReader);
public static object Load (System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, bool useRestrictiveXamlReader);
static member Load : System.IO.Stream * System.Windows.Markup.ParserContext * bool -> obj
Public Shared Function Load (stream As Stream, parserContext As ParserContext, useRestrictiveXamlReader As Boolean) As Object

Parameters

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback .

Submit and view feedback for

This product