Skip to main content
A newer version of this page is available. .

How to: Implement Conditional Formatting for Rows

The following sample demonstrates how to change the appearance of grid rows based on a condition.

<Window x:Class="ConditionalRowFormatting.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
    xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
    xmlns:local="clr-namespace:ConditionalRowFormatting" 
    Title="Window1" 
    Height="430" 
    Width="610">

    <Window.Resources>
        <ResourceDictionary>
            <local:SimpleDataList x:Key="simpleSource" InitCount="25" />
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <dxg:GridControl ItemsSource="{StaticResource simpleSource}" AutoGenerateColumns="AddNew">
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" AllowConditionalFormattingMenu="True">
                    <dxg:TableView.FormatConditions>
                        <dxg:ColorScaleFormatCondition Expression="[Int]" PredefinedFormatName="RedWhiteBlueColorScale" />
                    </dxg:TableView.FormatConditions>
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>