I got a button inside a grid that contains many other buttons and controls such as this
<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 is supposed to be enabled.
The problem I'm having is that even though I set the inside button to be enabled, it stays disabled, probably because its parent is disabled.
Is there any way to override this behavior and force the button to be enabled?
I'm using it for a case where there's a long process running in the background, so all the UI actions except for cancelling the process should be disabled.
Thanks!
No. Setting IsEnabled
property to false leads to disabling all the nested visual elements. One should think of element's contents as parts of its being. Disabling the element means disabling all of its parts.
The easiest workaround is to change the markup to meet your needs. I would rather bring the Cancel button out of this Grid
so it's never affected by IsEnabled
property of the Grid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With