WPF Datagrid issue: Cannot freeze this Storyboard timeline tree for use across threads

Sep 25, 2009 at 9:09 PM

 I am currently using the WPF datagrid, and wanted to add some animation to it.  I currently want to highlight a row (which can be green or white) when the user hovers over it (in my example, the row becomes lightblue), and on mouseleave, change the row back to it's original color.  I have this value in the view model (whether it's white or green).  So basically i want the row to fade back to it's original color after the mouse leaves the row.

I am currently setting this row color using my colorConverter but i am getting this error.

Cannot freeze this Storyboard timeline tree for use across threads

 

i've seen some articles such as this one but it does not solve my problem because i am not able to set my colors dynamically:

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9336022f-badb-4b40-a86c-a50ab1a64ba5

 

my code looks like this:

 

<Grid.Resources>
            <conv:ColorConverter x:Key="colorConverter" />
        </Grid.Resources>

 

 

<EventTrigger RoutedEvent="UIElement.MouseEnter">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames 
                                            Storyboard.TargetProperty="(tk:DataGridRow.Background).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="00:00:00.1" Value="LightBlue" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="UIElement.MouseLeave">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(tk:DataGridRow.Background).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="00:00:00.1" Value="{Binding Path=HighlightGreen, Converter={StaticResource colorConverter}}"></SplineColorKeyFrame>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>

 

can this be done in xaml?  any help would be appreciated!