XamlReader.Load Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Odczytuje dane wejściowe XAML i zwraca katalog główny odpowiedniego drzewa obiektów.
Przeciążenia
| Load(Stream) |
Odczytuje dane wejściowe XAML w określonej kodzie Stream i zwraca Object element, który jest katalogiem głównym odpowiedniego drzewa obiektów. |
| Load(XamlReader) |
Odczytuje dane wejściowe XAML za pośrednictwem podanego XamlReader obiektu i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów. |
| Load(XmlReader) |
Odczytuje dane wejściowe XAML w określonej kodzie XmlReader i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów. |
| Load(Stream, Boolean) | |
| Load(Stream, ParserContext) |
Odczytuje dane wejściowe XAML w określonej kodzie Stream i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów. |
| Load(XmlReader, Boolean) | |
| Load(Stream, ParserContext, Boolean) |
Load(Stream)
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
Parametry
- stream
- Stream
Kod XAML do załadowania w postaci strumienia.
Zwraca
Obiekt w katalogu głównym utworzonego drzewa obiektów.
Wyjątki
stream to null.
Przykłady
Poniższy przykład zapisuje element w ButtonMemoryStream klasie przy użyciu XamlWriter klasy . Strumień jest następnie ładowany z powrotem do Button metody statycznej Load w XamlReader klasie.
// 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)
Zobacz też
Dotyczy
Load(XamlReader)
Odczytuje dane wejściowe XAML za pośrednictwem podanego XamlReader obiektu i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów.
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
Parametry
- reader
- XamlReader
Obiekt XamlReader. Oczekuje się, że zostanie to zainicjowane przy użyciu wejściowego kodu XAML.
Zwraca
Obiekt, który jest katalogem głównym utworzonego drzewa obiektów.
Wyjątki
reader to null.
Uwagi
Dane wejściowe XamlReader mogą mieć wartość Baml2006Reader. W ten sposób można załadować kod BAML w czasie wykonywania lub do celów narzędzi lokalizacyjnych.
Dotyczy
Load(XmlReader)
Odczytuje dane wejściowe XAML w określonej kodzie XmlReader i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów.
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
Parametry
- reader
- XmlReader
Dane XmlReader wejściowe XAML zostały już załadowane do załadowania w formularzu XML.
Zwraca
Obiekt, który jest katalogem głównym utworzonego drzewa obiektów.
Wyjątki
reader to null.
Przykłady
Poniższy przykład konwertuje element Button na ciąg przy użyciu XamlWriter klasy . Ciąg jest następnie ładowany z powrotem do Button klasy przy użyciu metody statycznej XamlReaderLoad.
// 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)
Zobacz też
Dotyczy
Load(Stream, Boolean)
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
Parametry
- stream
- Stream
- useRestrictiveXamlReader
- Boolean
Zwraca
Dotyczy
Load(Stream, ParserContext)
Odczytuje dane wejściowe XAML w określonej kodzie Stream i zwraca obiekt, który jest katalogiem głównym odpowiedniego drzewa obiektów.
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
Parametry
- stream
- Stream
Strumień zawierający dane wejściowe XAML do załadowania.
- parserContext
- ParserContext
Informacje kontekstowe używane przez analizator.
Zwraca
Obiekt, który jest katalogem głównym utworzonego drzewa obiektów.
Wyjątki
Zobacz też
Dotyczy
Load(XmlReader, Boolean)
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
Parametry
- reader
- XmlReader
- useRestrictiveXamlReader
- Boolean
Zwraca
Dotyczy
Load(Stream, ParserContext, Boolean)
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
Parametry
- stream
- Stream
- parserContext
- ParserContext
- useRestrictiveXamlReader
- Boolean