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
295
Grid Row Color
posted

I have a requirement where my grid row color is determined by a cell value within that row.  I have implemented that with the following code:

        <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ClipToBounds="True">

                <igDP:XamDataGrid Margin="10,0,20,0" Name="xamDataGrid_POC"  DataSource="{Binding}" MinHeight="200" MaxHeight="300"  VerticalAlignment="Top" Width="Auto" RecordsDeleting="xamDataGrid_POC_RecordsDeleting" RecordUpdated="xamDataGrid_POC_RecordUpdated" RecordAdded="xamDataGrid_POC_RecordAdded" RecordAdding="xamDataGrid_POC_RecordAdding" FieldLayoutInitialized="ig_FieldLayoutInitialized" FieldPositionChanged="ig_FieldPositionChanged" RecordUpdating="xamDataGrid_POC_RecordUpdating" Loaded="xamDataGrid_POC_Loaded" LayoutUpdated="xamDataGrid_POC_LayoutUpdated" CellChanged="xamDataGrid_POC_CellChanged" CellUpdated="xamDataGrid_POC_CellUpdated" EditModeStarting="xamDataGrid_POC_EditModeStarting"   DataContext="{Binding}" BorderThickness="2" BorderBrush="Black" SnapsToDevicePixels="True">

                        <igDP:XamDataGrid.FieldLayoutSettings>

                              <igDP:FieldLayoutSettings HighlightAlternateRecords="False"/>

                        </igDP:XamDataGrid.FieldLayoutSettings>

 

                        <igDP:XamDataGrid.Resources>

 

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

                            <Setter Property="BorderThickness" Value="0,0,1,1"/>

                            <Setter Property="BorderBrush" Value="Black"/>

                        </Style>

 

 

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

                            <Style.Triggers>

                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.POCPriorityValue}" Value="High">

                                    <Setter Property="BackgroundAlternate" Value="Red" />

                                    <Setter Property="Background" Value="Red" />

                                </DataTrigger>

                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.POCPriorityValue}" Value="Medium">

                                    <Setter Property="BackgroundAlternate" Value="Yellow" />

                                    <Setter Property="Background" Value="Yellow" />

                                </DataTrigger>

                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.POCPriorityValue}" Value="Low">

                                    <Setter Property="BackgroundAlternate" Value="Green" />

                                    <Setter Property="Background" Value="Green" />

                                </DataTrigger>

                            </Style.Triggers>

                        </Style>

                    </igDP:XamDataGrid.Resources>

                </igDP:XamDataGrid>

 

The problem is that the row color is not added when rows are inserted.  However, if I scroll the grid so the new row rolls off the screen and then scroll it back down the row is colored properly.

 

How can I force the row to draw the correct color immediately upon being inserted into the grid?

 

 

 

Parents Reply Children
No Data