我有一页
当按下按钮时,我希望它达到50%的透明度。
我曾经在按下按钮时显示默认的蓝色背景,并且通过在页面中使用VisualState(通过删除按钮按下的默认样式)将其删除。
我现在想应用透明样式。
我将标记修改为:
<VisualState x:Name="Pressed">
<Storyboard>
<PointerDownThemeAnimation Storyboard.TargetName="Grid"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
<DiscreteObjectKeyFrame KeyTime="0" Value="50"></DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
这是我的按钮之一:
<Button Name="btnDel" Grid.Row="4" Grid.Column="2" Width="75" Height="75" HorizontalAlignment="Center" >
<Button.Background>
<ImageBrush ImageSource="ms-appx:///Images/del.png" Stretch="Uniform"/>
</Button.Background>
</Button>
我得到的错误是:
未指定动画目标。
您将需要使用DoubleAnimation
到动画Grid
的Opacity
,像这样的-
<VisualState x:Name="Pressed">
<Storyboard>
<PointerDownThemeAnimation Storyboard.TargetName="Grid"/>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Grid"/>
</Storyboard>
</VisualState>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句