我希望TextBox的不透明度属性随动画而变化。 (0到1)
<Window x:Class="DataTriggerAnime.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DataTriggerAnime"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<Storyboard x:Key="MyAnimation">
<DoubleAnimation Storyboard.TargetName="text"
Storyboard.TargetProperty="Opacity"
To="1" Duration="0:0:4" />
</Storyboard>
</Window.Resources>
<StackPanel>
<TextBox Name="text" Text="ABC">
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding Path=IsOpen}" Value="True " Comparison="Equal">
<ei:ControlStoryboardAction Storyboard="{StaticResource MyAnimation}" ControlStoryboardOption="Play"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
</TextBox>
</StackPanel>
“ IsOpen”是布尔属性,在ViewModel中定义。 按下某个按钮时,“ IsOpen”将由false更改为true。持续时间为4秒。如果多次按下该按钮,则每隔4秒或更短的时间,我希望“ MyAnimation”从每次按下开始就开始。