试图从代码隐藏加载XAML时XAML解析异常 [英] xaml parse exception when attempting to load xaml from codebehind
问题描述
我有下面一行代码在Silverlight中的代码隐藏定义的:
I have the following line of code defined in codebehind in silverlight:
Path path = XamlReader.Load( "<Path Data=\"F1 M 44.207,34.0669C 44.4841,33.7278 44.7612,33.3886 45.0383,33.0494\" />" ) as Path;
不知道为什么它的发生......
No idea why it's happening...
推荐答案
作为异常状态,你缺少你的XAML文档中的默认命名空间。在<路径方式>
元素需要XML命名空间
As the exception states, you are missing the default namespace in your XAML document. The <Path>
element needs an XML namespace.
添加属性的xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation
到您的路径元素。
Add the attribute xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
to your Path element.
的 http://msdn.microsoft.com/en-us/library/ms747086.aspx
和参考,如果你不熟悉他们,因为XAML仅仅是XML,这里介绍了XML命名空间:
的 http://www.w3schools.com/xml/xml_namespaces.asp
And for reference, in case you're not familiar with them, as XAML is just XML, here is an introduction to XML namespaces: http://www.w3schools.com/xml/xml_namespaces.asp
这篇关于试图从代码隐藏加载XAML时XAML解析异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!