Back to Devexpress

GridCellData.SelectionState Property

wpf-devexpress-dot-xpf-dot-grid-dot-gridcelldata-dd6b67c5.md

latest3.1 KB
Original Source

GridCellData.SelectionState Property

Gets a value that indicates the cell’s selection state. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public SelectionState SelectionState { get; }
vb
Public ReadOnly Property SelectionState As SelectionState

Property Value

TypeDescription
SelectionState

A SelectionState enumeration value that specifies the cell’s selection state.

|

Available values:

NameDescription
None

A cell (or row) isn’t focused and selected.

| | Focused |

A cell (or row) is focused.

| | Selected |

A cell (or row) is selected.

| | FocusedAndSelected |

A cell is focused and selected.

| | CellMerge |

A cell (or row) isn’t focused and selected, and the cell merging feature is enabled (the TableView.AllowCellMerge property is set to true ).

| | Highlighted |

A cell (or row) is highlighted.

|

Example

This example demonstrates how to use the View’s CellStyle property to define a custom appearance for focused and selected cells.

View Example: Change the Appearance of Focused and Selected Cells

xaml
<Window.Resources>
    <Style x:Key="SelectionStateCellStyle" TargetType="dxg:LightweightCellEditor">
        <Style.Triggers>
            <Trigger Property="SelectionState" Value="Selected">
                <Setter Property="Background" Value="Red"/>
                <Setter Property="Foreground" Value="White"/>
            </Trigger>
            <Trigger Property="SelectionState" Value="FocusedAndSelected">
                <Setter Property="Background" Value="Gray"/>
                <Setter Property="Foreground" Value="Black"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
<Grid>
    <dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew" SelectionMode="Cell">
        <dxg:GridControl.View>
            <dxg:TableView AutoWidth="True" CellStyle="{StaticResource SelectionStateCellStyle}"/>
        </dxg:GridControl.View>
    </dxg:GridControl>
</Grid>

See Also

GridCellData Class

GridCellData Members

DevExpress.Xpf.Grid Namespace