简体   繁体   中英

xaml parse exception when attempting to load xaml from codebehind

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM