I have a C# WPF DataGrid . In administrator mode, user can highline and select rows in DataGrid and key down a "D" to remove them using PreviewKeyDown
. In operator mode, this feature will be disabled and user can only scroll and read rolls but cannot highline or select rows to delete.
I can get the rows to be highlined and removed. But I don't know how to disable this feature. I tried:
IsReadOnly = false
renders the DataGrid not scrollable Focusable = false
user can still highline and select the rows IsHitTestVisible = false
still visible.. How?
You could disable selection in the DataGrid
while still keeping sorting, scrolling etc. by setting IsEnabled="False"
on DataGridRow
.
This has the sideeffect that most elements get the "grayed-out"/disabled look, however this is not the case for TextBlocks
.
<DataGrid ...>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="IsEnabled" Value="False"/>
</Style>
</DataGrid.RowStyle>
<!-- ... -->
</DataGrid>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.