As mentioned in the comment, you can use the Binding.TargetUpdated event.
Occurs when a value is passed from the binding source to the binding target, but only for bindings with the NotifyOnTargetUpdated value set to true.
This means that if a value is inferred from the view model to the view and NotifyOnTargetUpdated == True from the binding, the TargetUpdated event is TargetUpdated . Therefore, it will be raised when the value is displayed initially or later, when you raise the INotifyPropertyChanged.PropertyChanged event in your view model.
<DataGridTextColumn Header="Last Trade Price" Binding="{Binding Path=LastTradePrice, NotifyOnTargetUpdated=True}"> <DataGridTextColumn.CellStyle> <Style TargetType="DataGridCell"> <Style.Triggers> <EventTrigger RoutedEvent="Binding.TargetUpdated"> <BeginStoryboard> <Storyboard> <ColorAnimation To="Aqua" Duration="0:0:0.3" AutoReverse="True" Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style> </DataGridTextColumn.CellStyle> </DataGridTextColumn>
Also, if you want to briefly notify you of a color change, you want to set AutoReverse="True" to ColorAnimation otherwise the Aqua color will remain. The only drawback of this solution is that it will also work when creating a DataGrid and loading the initial values .
There is also the Binding.SourceUpdated event, which works with NotifyOnSourceUpdated from the binding and works in the opposite direction to the TargetUpdated event. It will be launched when the new value is transferred from the view to view the model.
Gets or sets a value indicating whether to raise the SourceUpdated event when a value is passed from the binding target to the binding source.
By default, both NotifyOnTargetUpdated abd NotifyOnSourceUpdated will be set to false in order to save 2 additional events when the values ββare passed between the view and the view model.
dkozl source share