How to make WPF Datagrid Column non-focusable?
datagridtextcolumn, focus, wpf, wpfdatagrid
Solution
Use a 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}"/>
....
Problem
I have a WPF `DataGrid` being used for data entry but some `DataGridTextColumn` are information only and I have set their `IsReadOnly="True"` so their cells do not go into edit mode. However, they can still receive focus which I want to avoid. Is there a way to do this?