Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeListView.FormatConditionsSource Property

Gets or set the source from which the grid generates conditional formats.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

public IEnumerable FormatConditionsSource { get; set; }

#Property Value

Type Description
IEnumerable

The source from which the grid generates conditional formats.

#Remarks

You can define conditional formatting rules in a ViewModel and apply them to the GridControl. To do this, follow the steps below:

  1. Create a collection of conditional formatting rules in a ViewModel.
  2. Specify a data template that generates format conditions:

    <Window.Resources>
        <DataTemplate x:Key="BackgroundTemplate">
            <ContentControl>
                <dxg:FormatCondition 
                    FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"
                    ValueRule="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).Rule, RelativeSource={RelativeSource Self}, Converter={StaticResource FormatRuleConverter}}"
                    Value1="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).Value, RelativeSource={RelativeSource Self}}"
                    ApplyToRow="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).ApplyToRow, RelativeSource={RelativeSource Self}}"
                    PredefinedFormatName="LightRedFill"/>
            </ContentControl>
        </DataTemplate>
    </Window.Resources>
    
  3. Assign the conditional formatting rule collection to the FormatConditionsSource property and the format condition template to the FormatConditionGeneratorTemplate property:

    <dxg:GridControl ItemsSource="{Binding Orders}">
        <!-- ... -->
        <dxg:GridControl.View>
            <dxg:TreeListView FormatConditionsSource="{Binding Rules}"
                              FormatConditionGeneratorTemplate="{StaticResource BackgroundFormat}"/>
        </dxg:GridControl.View>
    </dxg:GridControl>
    

Refer to the following help topic for more information: How to: Bind the Grid to a Collection of Conditional Formatting Rules.

See Also