【发布时间】:2012-06-11 00:12:43
【问题描述】:
我正在使用 XamlReader() 读取一个 xaml 文件,它当然具有以下元素和属性:
<setter property="Property1" Value="Value1" />
是否有任何方法可以定位特定属性及其关联值?
我应该使用字符串函数解析字符串吗?
【问题讨论】:
我正在使用 XamlReader() 读取一个 xaml 文件,它当然具有以下元素和属性:
<setter property="Property1" Value="Value1" />
是否有任何方法可以定位特定属性及其关联值?
我应该使用字符串函数解析字符串吗?
【问题讨论】:
MSDN 文档显示使用 XmlReader 作为 XamlReader 的输入
// Load the button
StringReader stringReader = new StringReader(savedButton);
XmlReader xmlReader = XmlReader.Create(stringReader);
Button readerLoadButton = (Button)XamlReader.Load(xmlReader);
http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlreader.aspx
您可以只使用 XmlReader 来获取属性。
http://msdn.microsoft.com/en-us/library/cc189056%28VS.95%29.aspx
您将在 MSDN 示例中显示的 switch 语句中使用 XmlNodeType.Attribute,首先在 XmlNodeType.Element 案例中注明您所在的节点。
【讨论】: