Animating the background of a new entry added to the XamDataGrid

Okay, I spent 2 days trying to figure out how to do this and so far I have gotten a "FAIL" grade.

The construction is as follows:

  • The ViewModel class provides a public ObservableCollection property called People.
  • The XAML view is bound to this property

The desired behavior is this:

  • Add new face to collection ViewModel
  • The view animates the background of the new record as it appears in the XamDataGrid, mostly blinking red for 2 seconds.

I have tried connecting the InitializeRecord grid to the RoutedEvent property of the EventTrigger, to no avail. (Invalid event name, so I assume it is not a RoutedEvent)

Also, since I am trying my best MVVM, I would like to avoid any solution that requires code changes. XAML just please.

+1


a source to share


1 answer


Add a property to your People class, say newRow. Then use a data trigger on the newRow property to apply the new style to the CellValuePresenter to change its background color to whatever you like. Internally, you can change the value of newRow to disable the trigger.



    <DataTrigger Binding="{Binding .DataItem[IsRecentUpdate]}" Value="True">
      <Setter Property="Background" Value="#FFFFE87C" />
      <Setter Property="BackgroundHover" Value="#FFFFE87C" />
      <Setter Property="BackgroundActive" Value="#FFFFE87C" />
      <Setter Property="BackgroundSelected" Value="#FFFFE87C" />
    </DataTrigger>

      

+1


a source







All Articles