Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
xamDataGrid - Animation of DataRecordPresenter Background color using DataTrigger
posted

Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

We are trying to change the background on DataRecordPresenter to animate on the basis of a DataTrigger. The data trigger is firing but our problem is how to get at the Background property to change it.  It takes a Brush but the ColorAnimationUsingKeyFrames returns a SolidColorBrush?

 

I am getting the exception "'System.Windows.Media.Animation.ColorAnimationUsingKeyFrames' animation object cannot be used to animate property 'Background' because it is of incompatible type 'System.Windows.Media.Brush'."  with the below code.

 

<Storyboard x:Key="storyboard1">

    <ColorAnimationUsingKeyFrames

                            Storyboard.TargetProperty="Background"

                            Duration="0:0:6"

                            FillBehavior="HoldEnd" RepeatBehavior="Forever">

        <ColorAnimationUsingKeyFrames.KeyFrames>

 

            <LinearColorKeyFrame Value="Red" KeyTime="0:0:2" />

            <DiscreteColorKeyFrame Value="Yellow" KeyTime="0:0:2.5" />

            <SplineColorKeyFrame Value="Green" KeyTime="0:0:4.5" KeySpline="0.6,0.0 0.9,0.00" />

        </ColorAnimationUsingKeyFrames.KeyFrames>

    </ColorAnimationUsingKeyFrames>

</Storyboard>

 

<Style TargetType="{x:Type igDP:DataRecordPresenter}">                              

    <Style.Triggers>

        <DataTrigger Binding="{Binding Path=DataItem.IsNew}" Value="True">

            <DataTrigger.EnterActions>

                <BeginStoryboard Storyboard="{StaticResource storyboard1}" x:Name="startOn"/>

            </DataTrigger.EnterActions>

            <DataTrigger.ExitActions>

                <StopStoryboard BeginStoryboardName="startOn" />

            </DataTrigger.ExitActions>

        </DataTrigger>

     </Style.Triggers>

</Style>

 

We were thinking that the target property should be something like

 

(Control.Background).(SolidColorBrush.Color)

 

Please can you point us in the right direction?

Parents Reply Children
No Data