■ DataViewBase 클래스의 CellStyle 속성을 사용해 선택한 셀 모양을 변경하는 방법을 보여준다.
▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<Window.Resources> <Style x:Key="CellStyleKey" TargetType="dxg:CellContentPresenter"> <Style.Triggers> <Trigger Property="SelectionState" Value="Selected"> <Setter Property="Background" Value="Red" /> </Trigger> <Trigger Property="SelectionState" Value="Focused"> <Setter Property="Background" Value="Green" /> <Setter Property="TextBlock.Foreground" Value="Pink" /> </Trigger> <Trigger Property="SelectionState" Value="FocusedAndSelected"> <Setter Property="Background" Value="Gray" /> <Setter Property="TextBlock.Foreground" Value="Black" /> </Trigger> </Style.Triggers> </Style> <Style x:Key="FocusedRowStyle" TargetType="dxg:GridRowContent"> <Style.Triggers> <Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True"> <Setter Property="Background" Value="Gray" /> <Setter Property="Foreground" Value="White" /> </Trigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew" SelectionMode="Cell"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AllowGrouping="False" CellStyle="{StaticResource CellStyleKey}"> </dxg:TableView> </dxg:GridControl.View> </dxg:GridControl> </Grid> |