How to make WPF Datagrid Column inactive?

I have a WPF DataGrid that is used for data entry, but some DataGridTextColumn are only information, and I set them IsReadOnly="True" so that their cells do not go into edit mode. However, they can still get the trick I want to avoid.

Is there any way to do this?

+7
source share
1 answer

Use the cell style and set Focusable = False.

 <Page.Resources> <Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}"> <Setter Property="Focusable" Value="False"/> </Style> </Page.Resources> <DataGrid ItemsSource="{Binding Items}" ...> <DataGrid.Columns> <DataGridTextColumn CellStyle="{StaticResource CellStyle}" IsReadOnly="True" Header="Name" Binding="{Binding Name}"/> .... 
+11
source

All Articles