There is a class representing the player (I give a simplified version):
class Player : INotifyPropertyChanged { public string Name { get; } int rank; public int Rank { get { return rank; } set { rank = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Rank")); } } public event PropertyChangedEventHandler PropertyChanged; public Player(string name) { Name = name; } } A collection of these Players is displayed, let's say, in ItemsControl:
<ItemsControl Name="icPlayers"> <ItemsControl.ItemTemplate> <DataTemplate> <Border Margin="0,2.5" Padding="5" BorderThickness="1" BorderBrush="DarkBlue"> <StackPanel> <TextBlock Text="{Binding Path=Name, Mode=OneTime}" FontWeight="Bold"/> <StackPanel Orientation="Horizontal"> <TextBlock Text="Рейтинг:" Margin="0,0,3,0"/> <TextBlock Text="{Binding Path=Rank, Mode=OneWay}" FontWeight="DemiBold"/> </StackPanel> </StackPanel> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> External forces change the player's rating (not often, not more than 1 time in a few seconds).
Is it possible to make WPF animations (not fundamentally) so that when the rating changes, the number in TextBox changes smoothly from the current value to the new, say, in 0.2 seconds?
I can, of course, start a timer in the setter, but I don’t like this solution.
