简体   繁体   中英

DoubleAnimation duration property in metro?

This should work in WPF:

DoubleAnimation d = new DoubleAnimation();
d.From = box.Width;
d.To = 1000;
d.Duration = new Duration(TimeSpan.FromSeconds(1)) ; 

However, in metro (windows 8), the last line is giving me the error:

'Windows.UI.Xaml.Duration' does not contain a constructor that takes 1 arguments

Intelisense also seems to think Duration needs no parameters.

Any ideas/work arounds? Is my installation broken?

use

d.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(1));

which is different than Windows.UI.Xaml.Duration and, as the OP reported, doesn't work. Does someone have a solution?

EDIT: have you tried setting TimeSpan directly?

d.Duration.TimeSpan = TimeSpan.FromSeconds(1);

Check out the MSDN documentation.

您需要在DurationHelper上使用静态方法FromTimeSpan创建持续时间。

d.Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(1));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM