Value Type Duration is not allowed on property Duration in XAML

耗尽温柔 提交于 2019-12-24 02:14:18

问题


I am trying to do the following with an ordinary Windows Metro style application:

public class MyButton : Button
{
    public Duration Duration { get; set; }
}
<Grid>
    <local:MyButton Duration="0:0:0.2" />
</Grid>

But I receive the error: Value Type Duration is not allowed on property Duration in XAML

Any idea what I might be doing wrong? Any help would be greatly appreciated.


回答1:


This is a bug in the Visual Studio 11 Beta XAML compiler. You cannot set user-defined value type properties via XAML.

This bug has been fixed and the fix should be present in the next release of Visual Studio 11.




回答2:


For now my workaround has been to expose my duration properties as string...



来源:https://stackoverflow.com/questions/9994845/value-type-duration-is-not-allowed-on-property-duration-in-xaml

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