心如止水

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

xaml –> UIElement

public static FrameworkElement GetElementFromXamlString(string xaml)

        {

            StringReader stringReader = new StringReader(xaml);

            XmlReaderSettings readersettings = new XmlReaderSettings();

            readersettings.ConformanceLevel = ConformanceLevel.Fragment;

            XmlReader xmlReader = XmlReader.Create(stringReader, readersettings);

            FrameworkElement element = (FrameworkElement)System.Windows.Markup.XamlReader.Load(xmlReader);

 

            return element;

        }

UIElement –>xaml

string str = System.Windows.Markup.XamlWriter.Save(element);

posted on 2008-10-07 15:03  cutebear  阅读(532)  评论(0编辑  收藏  举报