Gar*_*ett 7 wpf focus wpfdatagrid datagridtextcolumn
我有一个WPF DataGrid用于数据输入,但有些DataGridTextColumn只是信息,我设置了IsReadOnly="True"他们的单元格不进入编辑模式.但是,他们仍然可以获得我想要避免的焦点.
有没有办法做到这一点?
Phi*_*hil 12
使用单元格样式并设置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}"/>
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3651 次 |
| 最近记录: |