试图从代码隐藏加载XAML时XAML解析异常 [英] xaml parse exception when attempting to load xaml from codebehind

查看:167
本文介绍了试图从代码隐藏加载XAML时XAML解析异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面一行代码在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆