views:

469

answers:

1

Ok, I've spent 2 days trying to work out how to do this and have so far achieved a score of 'FAIL'.

The design is this:

  1. A ViewModel class exposes a public ObservableCollection property called People.
  2. A XAML view is bound to this property

The desired behaviour is this:

  1. Add a new Person to the ViewModel's collection
  2. The View animates the background of the new record as it appears in the XamDataGrid, basically flashing it red for 2 seconds.

I've tried hooking the grid 's InitializeRecord into the RoutedEvent property of an EventTrigger, to no avail. (Invalid Event Name, so I assume this is not a RoutedEvent)

Also, as I'm trying to keep as MVVM as possible, I'd like to avoid any solution which requires code-behind changes. XAML only please.

A: 

Add a property to your People class, say newRow. Then use a data trigger on the newRow property to apply a 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>
jas