This topic has not yet been rated - Rate this topic

XamlServices Class

Provides higher-level services (static methods) for the common XAML tasks of reading XAML and writing an object graph; or reading an object graph and writing XAML file output for serialization purposes.

System.Object
  System.Xaml.XamlServices

Namespace:  System.Xaml
Assembly:  System.Xaml (in System.Xaml.dll)
public static class XamlServices

The XamlServices type exposes the following members.

  Name Description
Public method Static member Load(Stream) Loads a Stream source for a XAML reader and writes its output as an object graph.
Public method Static member Load(String) Loads a Stream source for a XAML reader and returns an object graph.
Public method Static member Load(TextReader) Creates a XAML reader from a TextReader, and returns an object graph.
Public method Static member Load(XamlReader) Loads a specific XAML reader implementation and returns an object graph.
Public method Static member Load(XmlReader) Loads a specific XML reader implementation and returns an object graph.
Public method Static member Parse Reads XAML as string output and returns an object graph.
Public method Static member Save(Object) Processes a provided object tree into a XAML node representation, and returns a string representation of the output XAML.
Public method Static member Save(Stream, Object) Processes a provided object graph into a XAML node representation and then into an output stream for serialization.
Public method Static member Save(String, Object) Processes a provided object graph into a XAML node representation and then writes it to an output file at a provided location.
Public method Static member Save(TextWriter, Object) Processes a provided object graph into a XAML node representation and then into an output that goes to the provided TextWriter.
Public method Static member Save(XamlWriter, Object) Processes a provided object graph into a XAML node representation and then writes it to the provided XAML writer.
Public method Static member Save(XmlWriter, Object) Processes a provided object graph into a XAML node representation and then writes it to the provided XmlWriter.
Public method Static member Transform(XamlReader, XamlWriter) Connects a XamlReader and a XamlWriter to use a common XAML node set intermediary. Potentially transforms the content, depending on the types of readers and writers that are provided.
Public method Static member Transform(XamlReader, XamlWriter, Boolean) Connects a XamlReader and a XamlWriter to use a common XAML node set intermediary. Potentially transforms the content, depending on the types of readers and writers that are provided. Provides a parameter for specifying whether to close the writer after the call is completed.
Top

The modes of the XamlServices class that are used in the most common XAML reading and writing scenarios rely on creating instances of XAML readers and XAML writers. These readers and writers are specialized but internal implementations of public classes, such as XmlReader, XamlXmlReader, and XamlObjectWriter. To use XamlServices for most scenarios, you can rely on the default internal implementations to obtain the results that you want. For more specialized scenarios, you might define readers and writers yourself, and then pass them as arguments for overloads of the XamlServices methods.

Important note Important

XamlServices is not the recommended XAML reading or XAML writing API set if you are processing WPF-defined types, or types based on WPF. For WPF usage, use System.Windows.Markup.XamlReader for reading or loading XAML (or BAML); and System.Windows.Markup.XamlWriter for writing back XAML. These classes use .NET Framework XAML Services APIs and the XAML readers and XAML writers internally in their implementation; however, they also provide support and specialized XAML schema context for WPF-specific concepts, such as optimizations for dependency properties and WPF known types.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ