xaml parse exception when attempting to load xaml from codebehind

自古美人都是妖i 提交于 2020-01-14 14:42:06

问题


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...


回答1:


As the exception states, you are missing the default namespace in your XAML document. The <Path> element needs an XML namespace.

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

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



来源:https://stackoverflow.com/questions/6935078/xaml-parse-exception-when-attempting-to-load-xaml-from-codebehind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!