2
我有一个Windows.UI.Xaml.Shape.Path对象。如何生成对应于该Path对象的xaml字符串。从UIElement对象动态生成xaml字符串
输入:Path对象
所需的输出: “路径数据=” M 120,10 200,L300" 中风= “黑”, “”
或有任何方法来计算从当前位置路径数据bounds属性?
我有一个Windows.UI.Xaml.Shape.Path对象。如何生成对应于该Path对象的xaml字符串。从UIElement对象动态生成xaml字符串
输入:Path对象
所需的输出: “路径数据=” M 120,10 200,L300" 中风= “黑”, “”
或有任何方法来计算从当前位置路径数据bounds属性?
试试这个
string s_output = System.Windows.Markup.XamlWriter.Save(yourpath);
,并重新加载使用
System.IO.StringReader stringReader = new System.IO.StringReader(s_output);
System.Xml.XmlReader xmlReader = System.Xml.XmlTextReader.Create(stringReader, new System.Xml.XmlReaderSettings());
Path yourpath= (Path)System.Windows.Markup.XamlReader.Load(xmlReader);
谢谢您的回复。代码在Wpf应用程序中工作。但我正在开发Windows8 metro样式应用程序,并且新框架没有XamlWriter类。那么有没有其他方法可以解决这个问题? – neethu 2012-08-01 05:50:09
@neethu - 我有类似的问题。你能解决XamlWriter问题吗? – devson 2013-01-26 13:56:27
也许xamlwriter是可用的。在win8.1中? – 2013-08-31 22:04:44