Enabling a specific button inside a disabled grid

I got a button inside the grid that contains many other buttons and controls, such as

<Grid IsEnabled="false"> <Grid.ColumnsDefinition> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnsDefinition> <Button Content="Run"/> <Button Grid.Column="1" Content="Test"/> <Button Grid.Column="2" Content="Cancel" IsEnabled="true"/> </Grid> 

As you can see, the grid is disabled, but the cancel button inside it must be enabled.

The problem I am facing is that although I set the internal button to turn it on, it remains disabled, probably because its parent is disabled.

Is there a way to override this behavior and make the button turn on?

I use it for the case when a lengthy process runs in the background, so all user interface actions, with the exception of canceling the process, should be disabled.

Thanks!

+6
source share
1 answer

Not. Setting the IsEnabled property to false IsEnabled all nested visual elements. We need to think about the content of the elements as part of its being. Disabling an element means disabling all its parts.

The easiest way is to change the layout to meet your needs. I would rather bring the Cancel button out of this Grid so that it never IsEnabled Grid property

+2
source

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


All Articles