如何在 WPF Datagrid 中禁用编辑单元格? [英] How can I disable editing cells in a WPF Datagrid?
问题描述
我正在 Windows Presentation Foundation 中构建数据网格,但遇到了问题.当用户双击我的数据网格中的单元格时,该单元格进入编辑模式.我想阻止这种情况.相反,我希望用户能够选择整行 - 而不是编辑其中的值.
I'm constructing a datagrid in Windows Presentation Foundation, and I have a problem. When a user double-clicks on a cell in my datagrid, the cell goes into edit mode. I want to prevent that. Instead I want users to be able to select the full row - not edit values in it.
我怎样才能让双击选择整行而不是将点击的单元格置于编辑模式?
How can I make it so that double-clicks select the full row instead of putting the clicked-on cell in edit mode?
推荐答案
WPF DataGrid
有一个 IsReadOnly
属性,您可以将其设置为 True
以确保用户无法编辑您的 DataGrid
的单元格.
The WPF DataGrid
has an IsReadOnly
property that you can set to True
to ensure that users cannot edit your DataGrid
's cells.
您还可以根据需要为 DataGrid
中的各个列设置此值.
You can also set this value for individual columns in your DataGrid
as needed.
这篇关于如何在 WPF Datagrid 中禁用编辑单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!