If I want to disable button, I need to set IsEnabled to false and remove Command binding, really? Why is it so difficult?
ICommand.CanExecute is used to determine the IsEnabled state of a Button. So if you want to disable a Button when a certain condition is met you have to make sure CanExecute returns false.
Of course, you are right. And in Avalonia I can bind method without creating Command. But why this simpliest property doesn't work as in WPF? I don't understand.
You _can_ set IsEnabled = false without creating a command.
So this button will be useless. This is my code:
Width="200"
Height="30"
Command="{Binding ErrorClick}"
Content="{Binding ErrorClickCount, StringFormat=Clicked {0} time}"
NormalBackground="{DynamicResource ErrorBrush}"
PressedBackground="{DynamicResource HoverBrush}" />
I want to be able to change IsEnabled prop via code. I tried to set IsEnabled = false, but nothing changed, neither button's style nor its behaviour. So I tried to set IsEnabled = false and remove Command="{Binding ErrorClick}", and that's worked, button became disabled. But I don't wanna remove command binding if I just need to disable button.
Ok, it looks like WPF does essentially enabledState = button.Command.Enabled && button.IsEnabled whereas we ignore button.IsEnabled when a command is set.
We should change our behavior to match that of WPF's.
@katsukosensey this project is in BETA. Beta means there will be bugs. If you don't like that then use software that is of release quality. We're all volunteers here so please moderate your tone accordingly.
Thank you for answer and I apologize if my tone was rude. I just wanted to understand the problem. Thank you for great work and responsiveness.
No problem. I'm going to re-open the issue if because I plan to fix it in the next few days. I'll close it when it's fixed.
Most helpful comment
Thank you for answer and I apologize if my tone was rude. I just wanted to understand the problem. Thank you for great work and responsiveness.