Edit

Bagikan melalui


XamlServices.Save Method

Definition

Processes a provided object graph into a XAML node representation and then into an output format for serialization.

Overloads

Save(Object)

Processes a provided object tree into a XAML node representation, and returns a string representation of the output XAML.

Save(Stream, Object)

Processes a provided object graph into a XAML node representation and then into an output stream for serialization.

Save(TextWriter, Object)

Processes a provided object graph into a XAML node representation and then into an output that goes to the provided TextWriter.

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.

Save(XamlWriter, Object)

Processes a provided object graph into a XAML node representation and then writes it to the provided XAML writer.

Save(XmlWriter, Object)

Processes a provided object graph into a XAML node representation and then writes it to the provided XmlWriter.

Save(Object)

Processes a provided object tree into a XAML node representation, and returns a string representation of the output XAML.

public:
 static System::String ^ Save(System::Object ^ instance);
public static string Save (object instance);
static member Save : obj -> string
Public Shared Function Save (instance As Object) As String

Parameters

instance
Object

The root of the object graph to process.

Returns

The XAML markup output as a string.

Remarks

The output from this method is the ToString result of an XmlWriter that is created by the method call. That XmlWriter is created by using the following settings: XmlWriterSettings.Indent is true; and XmlWriterSettings.OmitXmlDeclaration is true.

The returned string can be loaded as valid XML through the Create method if you processed the string into a stream, or into a reader more specifically dedicated for XAML.

Applies to

Save(Stream, Object)

Processes a provided object graph into a XAML node representation and then into an output stream for serialization.

public:
 static void Save(System::IO::Stream ^ stream, System::Object ^ instance);
public static void Save (System.IO.Stream stream, object instance);
static member Save : System.IO.Stream * obj -> unit
Public Shared Sub Save (stream As Stream, instance As Object)

Parameters

stream
Stream

The destination stream.

instance
Object

The root of the object graph to process.

Exceptions

stream input is null.

Remarks

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

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:
 static void Save(System::IO::TextWriter ^ writer, System::Object ^ instance);
public static void Save (System.IO.TextWriter writer, object instance);
static member Save : System.IO.TextWriter * obj -> unit
Public Shared Sub Save (writer As TextWriter, instance As Object)

Parameters

writer
TextWriter

The TextWriter that writes the output.

instance
Object

The root of the object graph to process.

Exceptions

writer input is null.

Applies to

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:
 static void Save(System::String ^ fileName, System::Object ^ instance);
public static void Save (string fileName, object instance);
static member Save : string * obj -> unit
Public Shared Sub Save (fileName As String, instance As Object)

Parameters

fileName
String

The name and location of the file to write the output to.

instance
Object

The root of the object graph to process.

Exceptions

fileName is an empty string.

fileName is null.

Remarks

The fileName parameter value is used as the outputFileName input for a call to XmlWriter.Create, which creates a XmlWriter as part of the method call.

Applies to

Save(XamlWriter, Object)

Processes a provided object graph into a XAML node representation and then writes it to the provided XAML writer.

public:
 static void Save(System::Xaml::XamlWriter ^ writer, System::Object ^ instance);
public static void Save (System.Xaml.XamlWriter writer, object instance);
static member Save : System.Xaml.XamlWriter * obj -> unit
Public Shared Sub Save (writer As XamlWriter, instance As Object)

Parameters

writer
XamlWriter

The XamlWriter implementation to use.

instance
Object

The root of the object graph to process.

Exceptions

writer input is null.

Remarks

You should typically use this signature only in the following cases:

  • You defined your own implementation of a XamlWriter.

  • You specified settings for the XamlWriter that differ from the default settings.

Applies to

Save(XmlWriter, Object)

Processes a provided object graph into a XAML node representation and then writes it to the provided XmlWriter.

public:
 static void Save(System::Xml::XmlWriter ^ writer, System::Object ^ instance);
public static void Save (System.Xml.XmlWriter writer, object instance);
static member Save : System.Xml.XmlWriter * obj -> unit
Public Shared Sub Save (writer As XmlWriter, instance As Object)

Parameters

writer
XmlWriter

The XmlWriter implementation to use.

instance
Object

The root of the object graph to process.

Exceptions

writer input is null.

Applies to