在 Silverlight 4 项目中,我有一个扩展 Canvas 的类:
public class AppendageCanvas : Canvas
{
public float Friction { get; set; }
public float Restitution { get; set; }
public float Density { get; set; }
}
我在 Blend 中使用此画布,将其拖动到另一个控件上并设置自定义属性:
替代文本 http://www.farseergames.com/storage/share/PropertyInBlend.Png http://www.farseergames.com/storage/share/PropertyInBlend.Png
当我运行应用程序时,在包含自定义画布的控件上调用 InitializeComponent 时出现以下错误:
Failed to create a 'Windows.Foundation.Single' from the text '0.0'
替代文本 http://www.farseergames.com/storage/share/SilverlightError.Png http://www.farseergames.com/storage/share/SilverlightError.Png
我不确定为什么 Silverlight 无法将此属性从 Xaml 中的字符串表示形式转换为浮点数。
有人有主意吗?
The 本机文本语法 http://msdn.microsoft.com/en-us/library/dd638655(v=VS.95).aspx#native_text_syntaxes子主题列出了 Xaml 本身知道如何转换的类型。基本上支持的原始类型是double
, int
, bool
and string
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)