Value Type Duration is not allowed on property Dur

2019-07-14 03:29发布

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.

2条回答
等我变得足够好
2楼-- · 2019-07-14 03:52

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.

查看更多
Viruses.
3楼-- · 2019-07-14 04:10

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

查看更多
登录 后发表回答