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.

  NameDescription
Public methodStatic memberLoad(Stream)Loads a Stream source for a XAML reader and writes its output as an object graph.
Public methodStatic memberLoad(String)Loads a Stream source for a XAML reader and returns an object graph.
Public methodStatic memberLoad(TextReader)Creates a XAML reader from a TextReader, and returns an object graph.
Public methodStatic memberLoad(XamlReader)Loads a specific XAML reader implementation and returns an object graph.
Public methodStatic memberLoad(XmlReader)Loads a specific XML reader implementation and returns an object graph.
Public methodStatic memberParseReads XAML as string output and returns an object graph.
Public methodStatic memberSave(Object)Processes a provided object tree into a XAML node representation, and returns a string representation of the output XAML.
Public methodStatic memberSave(Stream, Object)Processes a provided object graph into a XAML node representation and then into an output stream for serialization.
Public methodStatic memberSave(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 methodStatic memberSave(TextWriter, Object)Processes a provided object graph into a XAML node representation and then into an output that goes to the provided TextWriter.
Public methodStatic memberSave(XamlWriter, Object)Processes a provided object graph into a XAML node representation and then writes it to the provided XAML writer.
Public methodStatic memberSave(XmlWriter, Object)Processes a provided object graph into a XAML node representation and then writes it to the provided XmlWriter.
Public methodStatic memberTransform(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 methodStatic memberTransform(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 noteImportant

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.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft