开发者

Animating a databound progressbar in Silverlight declaratively (no code-behind)

开发者 https://www.devze.com 2023-01-05 12:13 出处:网络
How does one animate开发者_高级运维 a ProgressBar whose Value property is databound? <ProgressBar Height=\"25\" Margin=\"5\" Maximum=\"100\" Value=\"{Binding CurrentProgress}\">

How does one animate开发者_高级运维 a ProgressBar whose Value property is databound?

<ProgressBar Height="25" Margin="5" Maximum="100" Value="{Binding CurrentProgress}">

My data source would probably "jump" from value to value, usually from user input; for example - user performs action, and the progress bar jumps 20 points. I would want to be able to take the new number for ProgressBar.Value and smooth it over in the animation. Let's say the new value is 50 and the old value is 20. I would want some sort of XAML markup to dictate that the UI to smoothly slides from 20 to 50.

I want to do this declaratively with no code-behind. I'm fairly sure it's possible but I can't seem to fit in the pieces together. I have looked into Storyboards, but don't know how to trigger a storyboard when data changes. I have also looked into the TransitioningContentControl but am unsure how to link the transition with the ProgressBar control.


Try to add animation in ProgressBars Template event triger

<EventTrigger RoutedEvent="RangeBase.ValueChanged">
 <BeginStoryboard Storyboard="{StaticResource OnValueChanged1}"/>
</EventTrigger>
0

精彩评论

暂无评论...
验证码 换一张
取 消