WPF Datagrid deselects row when control is disabled

I have a program in which a user selects a row in a Datagrid, and then clicks the "Start recording" button. As long as the "write" occurs, they are not allowed to change the value selected in the datagrid, so I set IsEnabled to false. However, when the datagrid is set to disabled, it deselects the selected row, which twists any bindings that I have to the datagrid SelectedItem element.

Is there a way to save the selected datagrid row even if the control is disabled?

Edit: This does not happen on Windows Vista, but it does on Windows 7.

+3
source share
3 answers

If you really want to “record” actions, but still keep the visual effects and interactions the same, why don’t you just add a check for the event that has been selected to ensure that the recording is not performed, and set e.Handled = true.

Alternatively, you can set IsHitTestVisible = false and prevent them from taking actions in the control, rather than disabling it directly.

Hope this helps.

0
source

Sorry, I know this post is a little old, but I could not find another solution for this elsewhere.

This doesn't seem to be related to Vista \ 7, but with the release of Toolkit in February.

IsHitTestVisible = false, , , , . , .

, DataGrid , ( ). , , DataGrid. "", . , - .

, "PreviewKeyDown" e.Handdled = true. - , - , (, ). , , , , - , .

0

IsHitTestVisible = false .

Focusable = false.

ElementStyle / ElementEditingStyle datagrid ( , ..), .

, IsRecording.

In addition, you could change the appearance of “disabled” controls in the same style by setting their Opacity = 0.4, which gives them some sense of disconnection.

0
source

Source: https://habr.com/ru/post/1736183/


All Articles