■ XamlWriter 클래스 : XAML 구하기

----------------------------------------------------------------------------------------------------

using System;

using System.Text;

using System.Windows;

using System.Windows.Markup;

using System.Xml;

 

#region XAML 구하기 - GetXAML(frameworkTemplate)

 

/// <summary>

/// XAML 구하기

/// </summary>

/// <param name="frameworkTemplate">FrameworkTemplate 객체</param>

/// <returns>XAML</returns>

public string GetXAML(FrameworkTemplate frameworkTemplate)

{

    XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();

 

    xmlWriterSettings.Indent              = true;

    xmlWriterSettings.IndentChars         = new string(' ', 4);

    xmlWriterSettings.NewLineOnAttributes = true;

 

    StringBuilder stringBuilder = new StringBuilder();

 

    XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlWriterSettings);

 

    try

    {

        XamlWriter.Save(frameworkTemplate, xmlWriter);

    }

    catch(Exception)

    {

        return string.Empty;

    }

 

    return stringBuilder.ToString();

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요