如何通过 XAML 动画增加进度条? [英] How to increment progress bar through XAML animation?
本文介绍了如何通过 XAML 动画增加进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要放置一个需要 10 秒才能完成 100% 进度的进度条.它应该每秒增加 10%.我想要一种 XAML 方法.我知道如何使用 DispacherTimer
或类似的东西来做到这一点.如何仅使用 XAML 执行此操作?
I need to place a progress bar that takes 10 seconds to complete 100% progress. It should increment 10% per second. I would like a XAML approach. I know how to do that with a DispacherTimer
or similar thing. How can I do that with XAML only?
我有一些想法,但我不知道如何完成,甚至不知道是否有可能.
I have some idea, but I don't know how to finish it or even if it's possible.
<ProgressBar>
<ProgressBar.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<DoubleAnimation From="0" To="100" Duration="0:0:10"></DoubleAnimation>
</BeginStoryboard>
</EventTrigger>
</ProgressBar.Triggers>
</ProgressBar>
推荐答案
如何简单地使用 DoubleAnimation
动画 Value
属性使用超过 10 秒的线性插值?:
How about simply using a DoubleAnimation
that animates the Value
property using linear interpolation over 10 seconds?:
<ProgressBar Minimum="0" Maximum="100">
<ProgressBar.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="100" Storyboard.TargetProperty="Value" Duration="00:00:10" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ProgressBar.Triggers>
</ProgressBar>
这篇关于如何通过 XAML 动画增加进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文