这是我在有限的时间内能想到的最好的办法。如果需要的话,我明天可以帮你做进一步的工作。注意,我使用了CellTemplate的一个文本框,这使我能够使用TextChanged事件来触发着色。我不能让你的关键帧动画工作,所以我使用了着色动画。祝你好运!
<Window x:Class="CellFlashSpike.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Storyboard x:Key="IncreaseValueColourAnimation"
Duration="0:0:2"
AutoReverse="True">
<ColorAnimation Storyboard.TargetProperty="(TextBox.Foreground).(SolidColorBrush.Color)"
To="Red"/>
</Storyboard>
<DataTemplate x:Key="FlashTemplate">
<TextBox Width="50" Text="{Binding Path=.}">
<TextBox.Style>
<Style>
<Style.Triggers>
<EventTrigger RoutedEvent="TextBox.TextChanged">
<EventTrigger.Actions>
<BeginStoryboard>
<StaticResource ResourceKey="IncreaseValueColourAnimation"/>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</DataTemplate>
</Window.Resources>
<Grid>
<ListView ItemsSource="{Binding Numbers}">
<ListView.View>
<GridView>
<GridViewColumn CellTemplate="{StaticResource FlashTemplate}"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
namespace CellFlashSpike
{
public partial class Window1 : Window
{
public List<string> Numbers { get; set; }
public Window1()
{
Numbers = new List<string> { "3", "4" };
InitializeComponent();
DataContext = this;
}
}
}