我可以使用以下代码淡入/淡出
<Storyboard x:Name="EnterStoryboard">
<FadeOutThemeAnimation Storyboard.TargetName="PauseImage" />
</Storyboard>
<Storyboard x:Name="ExitStoryboard">
<FadeInThemeAnimation Storyboard.TargetName="PauseImage" />
</Storyboard>
淡入淡出:
EnterStoryboard.Begin();
淡出:
ExitStoryboard.Begin();
如果元素从一开始就隐藏(我尝试设置opacity=0
and visibility=collapsed
) ,我该如何淡入淡出。
编辑:
基于 AstiK 解决方案,这里是新Storyboard
的 s (而不是内置FadeInThemeAnimation
/ FadeOutThemeAnimation
)
<Storyboard x:Name="EnterStoryboard">
<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" From="0" To="1" Duration="00:00:00.3" Storyboard.TargetName="Image"/>
</Storyboard>
<Storyboard x:Name="ExitStoryboard">
<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:00.3" Storyboard.TargetName="Image"/>
</Storyboard>