100
conditional colors, alternate row colors plus blinking
posted

Howdy,

I have alternate row colors and conditional row colors, colors based on a numeric value in a column. 

However, now I have to add blinking to a row based on a bool value in column. 

Any hints? 

Thanks

Oskar

<igWPF:XamDataGrid.Resources>
                <Style TargetType="{x:Type igWPF:DataRecordCellArea}">
                    <Setter Property="Background">
                            <Setter.Value>
                                <SolidColorBrush Color="{Binding Path=Cells[Alarmlevel].Value, Converter={StaticResource alarmColorConverter}}">
                                </SolidColorBrush>
                            </Setter.Value>
                    </Setter>
                    <Setter Property="BackgroundAlternate">
                        <Setter.Value>
                            <SolidColorBrush Color="{Binding Path=Cells[Alarmlevel].Value, Converter={StaticResource alarmColorLowConverter}}">
                            </SolidColorBrush>
                        </Setter.Value>
                    </Setter>
  
                </Style>
Parents
  • 26880
    Offline posted

    Hello Oskar,

    In order to animate a row in the XamDataGrid based on a bool value in another column, I would recommend continuing with the idea of a Style for DataRecordCellArea, and utilize a DataTrigger with it. For example, you could continue binding to the Cells collection, and you could also bind to the underlying DataItem property to access your underlying type.

    The DataTrigger class has EnterActions and ExitActions, and I would recommend that you utilize a BeginStoryboard element pointed at a Storyboard with a ColorAnimation pointed at <BackgroundPropertyName>.Color. This DataTrigger could look like the following:

    <DataTrigger Binding="{Binding DataItem.Animate}" Value="True">
     <DataTrigger.EnterActions>
      <BeginStoryboard Storyboard="{StaticResource animateStory}" Name="beginStory"/>
     </DataTrigger.EnterActions>
     <DataTrigger.ExitActions>
      <StopStoryboard BeginStoryboardName="beginStory" />
     </DataTrigger.ExitActions>
    </DataTrigger>

    In this case, the "animateStory" Storyboard could look like the following:

    <Storyboard x:Key="animateStory">
      <ColorAnimation Duration="0:0:1" To="Red" RepeatBehavior="Forever" AutoReverse="True" Storyboard.TargetProperty="Background.Color"/>
    </Storyboard>

    I have attached a sample project to demonstrate the above. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XDGFlashingAnimationCase.zip
Reply Children
No Data