In a WPF project, I have an ItemsControl bound to a collection of the ViewModel. It's ItemTemplate contains an Image control bound to property of the object collection. I have a timer which fetches new images every minute from a JSON service and assigns them to that property bound to the Image.
What I wanna do is trigger a simple animation when that property changes. Particularly, I want to trigger a simple fade-out animation right before the new image is assigned to my property, that would involve the PropertyChanging event, and a fade-in animation on PropertyChanged so I would have a smooth transition from the old to new image in my View.
I've tried the following taken from another question but that triggers the animation after the property changes which isn't what I want:
<Image
x:Name="ChannelImage"
Width="230" Height="230"
Source="{Binding ImageByteArray, Converter={StaticResource ByteArrayToBitmapImageConverter},
NotifyOnTargetUpdated=True}">
<Image.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ChannelImage"
Storyboard.TargetProperty="Opacity"
BeginTime="0:0:0"
Duration="0:0:1"
To="0"/>
<DoubleAnimation
Storyboard.TargetName="ChannelImage"
Storyboard.TargetProperty="Opacity"
BeginTime="0:0:2"
Duration="0:0:1"
To="1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
Any help would be much appreciated.