在WPF中,我们如何将Duration定义为资源?

Zom*_*man 6 wpf xaml

我有一个持续时间(0:0:0.5),我在一些动画中使用,我想只在一个地方定义这个数字.我可以将double定义为

<Window.Resources>
    <sys:Double x:Key="GridWidth">400</sys:Double>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

但不确定如何将持续时间表示为资源.谢谢.

cod*_*zen 10

<Window.Resources>
    <Duration x:Key="aDuration">0:0:0.5</Duration>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

通常,您可以查看类型的MSDN doc以查看它们是否提供XAML语法.对于WPF类型,通常有:http://msdn.microsoft.com/en-us/library/ms602372.aspx.