如何在进入(悬停)按钮时使TextBlock
的动画开始
在TextBlock
我希望<EventTrigger RoutedEvent
位于Input2
MouseEnter
,我该怎么做
<EventTrigger RoutedEvent=Input2.MouseEnter
无法识别
按钮:
<Button Grid.Row="0" Name="Input2" Click="Input_Click" MouseEnter="Input_MouseEnter" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
<Button.Template>
<ControlTemplate>
<Border HorizontalAlignment="Center" VerticalAlignment="Center" >
<Image Source= "C:\Users\Luvaton\Documents\Visual Studio 2017\Projects\10KHours\10KHours\Media\input.png"
Width="40"
Height="40"/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
TextBlock
:
<TextBlock Grid.Row="0" Name="Input_Name1" Text="Input" FontSize="40" FontFamily="/10KHours;component/Font_count/#Dancing Script" VerticalAlignment="Center" Height="48" Margin="65.346,33.6,-102.081,36">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Input_Name1"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:5"
AutoReverse="true" RepeatBehavior="1x">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
答案 0 :(得分:2)
改变TextBlock
风格的基本思路是完全正确的。添加DataTrigger
并将其绑定到您要悬停的IsMouseOver
的{{1}}。使用Button
是获取所需信息的最简单方法。这是一个最小的例子:
IsMouseOver