在我的 WPF 应用程序中,我使用的是 DataGrid 控件。我允许用户重新排序列。但是,我必须确保前两列和最后一列不能重新排序。
所有列都是使用new DataGridTextColumn()
.
我想知道是否有人可以指导我完成此操作需要做什么?预先感谢您的帮助。
You can use the DataGrid.FrozenColumnCount
Property to not allow the users to move columns.
However, if you look at the documentation, you will see that you can only do this for the first x columns from the left side of the DataGrid
. For example, if you set the FrozenColumnCount
to 2
, the two left columns in the display are frozen.
Use DataGridColumn.CanUserReorder
property (set tis property to false
for columns, which can't be reordered).