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?
By default, you can edit items directly in the DataGrid. The user can enter edit mode in a cell by pressing F2 key or double tapping on a cell. Alternatively, you can set the DataGridColumn. IsReadOnly property to true to disable editing in specific columns of the DataGrid.
A Grid is a control for laying out other controls on the form (or page). A DataGrid is a control for displaying tabular data as read from a database for example.
WPF DataGrid (SfDataGrid) provides built-in row called AddNewRow. It allows user to add a new row to underlying collection. You can enable or disable by setting SfDataGrid.
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}"/>
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With