How to animate the Value ProgressBar property using the DoubleAnimation storyboard in Windows 8.1

I have a Windows 8.1 application with progress defined as follows

<ProgressBar x:Name="myProgressBar" Opacity="1" Minimum="0" Maximum="100" Value="0"/> 

I have the following StoryBoard animation defined as follows.

 <Storyboard x:Name="myStoryBoard"> <DoubleAnimation Storyboard.TargetName="myProgressBar" Storyboard.TargetProperty="Value" From="0" To="100" Duration="00:00:04" /> </Storyboard> 

This C # code behind calls the start function of the storyboard.

 myStoryBoard.Begin(); 

But I do not see any changes in the Value ProgressBar Property.

However, if I applied a similar StoryBoard animation to the Opacity property of the same ProgressBar, it works without problems, I see the ProgressBar disappearing as expected.

 <Storyboard x:Name="myOpacityStoryBoard"> <DoubleAnimation Storyboard.TargetName="myProgressBar" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:4"> </Storyboard> 

I'm not sure what is going on. I checked that Value Value is dual, like and how opacity. Am I doing something wrong?

I would be glad if someone could lead me in the right direction.

+5
source share
1 answer

You just need to add EnableDependentAnimation="True" to your animation.

 <Storyboard x:Name="myStoryBoard"> <DoubleAnimation Storyboard.TargetName="myProgressBar" Storyboard.TargetProperty="Value" EnableDependentAnimation="True" From="0" To="100" Duration="00:00:04" /> </Storyboard> 
+2
source

Source: https://habr.com/ru/post/1206556/


All Articles