トップ回答者
アニメーションの適用条件が理解できない

質問
-
UWPでアニメーションをさせようと思っていますが、アニメーション対象によってできたりできなかったりします。
下記コードでStoryboard.TargetProperty="Opacity"としてストーリーボードを起動した場合は透明度が下がる挙動が機能しています。
<StackPanel x:Name="LayoutRoot" Margin="10,133,-10,-133" >
<StackPanel.Resources>
<Storyboard x:Name="myStoryboard">
<DoubleAnimation From="0" To="1" Duration="00:00:3"
Storyboard.TargetName="a"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
</Storyboard>
</StackPanel.Resources>
<Rectangle x:Name="a" Fill="Blue" Width="200" Height="30" Margin="540,0">
</Rectangle>
</StackPanel>しかしStoryboard.TargetProperty="Height"とした場合は何の反応もありません。
<StackPanel x:Name="LayoutRoot" Margin="10,133,-10,-133" >
<StackPanel.Resources>
<Storyboard x:Name="myStoryboard">
<DoubleAnimation From="1" To="600" Duration="00:00:3"
Storyboard.TargetName="a"
Storyboard.TargetProperty="Height"
</Storyboard>
</StackPanel.Resources>
<Rectangle x:Name="a" Fill="Blue" Width="200" Height="30" Margin="540,0">
</Rectangle>
</StackPanel>指定するプロパティには何か条件があるのでしょうか?
教えていただきたいです。
回答
-
こんにちは。
DoubleAnimationのEnableDependentAnimationをTrueに設定してみてください。
DoubleAnimation.EnableDependentAnimation property
<Storyboard x:Name="myStoryboard"> <DoubleAnimation From="0" To="600" Duration="00:00:3" EnableDependentAnimation="True" Storyboard.TargetName="a" Storyboard.TargetProperty="Height"> </DoubleAnimation> </Storyboard>
- 編集済み いわさ Tak1waMVP, Moderator 2016年7月4日 7:20
- 回答としてマーク sauto 2016年7月4日 8:40
すべての返信
-
こんにちは。
DoubleAnimationのEnableDependentAnimationをTrueに設定してみてください。
DoubleAnimation.EnableDependentAnimation property
<Storyboard x:Name="myStoryboard"> <DoubleAnimation From="0" To="600" Duration="00:00:3" EnableDependentAnimation="True" Storyboard.TargetName="a" Storyboard.TargetProperty="Height"> </DoubleAnimation> </Storyboard>
- 編集済み いわさ Tak1waMVP, Moderator 2016年7月4日 7:20
- 回答としてマーク sauto 2016年7月4日 8:40