我有一个WPF DataGrid
用于数据输入,但是有些DataGridTextColumn
仅用作信息,我已经设置了它们的IsReadOnly="True"
,因此它们的单元格不会进入编辑模式。但是,他们仍然可以得到我要避免的焦点。
有没有办法做到这一点?
最佳答案
使用单元格样式并设置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}"/>
....
关于wpf - 如何使WPF Datagrid列不可聚焦?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10031559/