-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CanExecute can not change Button clickability #22652
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Closed similar issues:
|
Can repro this issue at Android platform on the latest 17.11.0 Preview 1.0(8.0.7/8.0.10/8.0.21). |
This looks related: #9753 |
FWIW I was able to get it working just fine https://github.com/drasticactions/MauiRepros/tree/main/MvvmTestCanExecute ![]() ![]() It may be that you didn't set up your model correctly? Maybe the library you are using is at fault? If you make a sample showing what you're doing that could help, or maybe run what I wrote above and see if it doesn't work for you? |
@drasticactions Hi, I made a sample, I use Mvvm Toolkit, and the public partial class MainViewModel : ObservableObject
{
[ObservableProperty]
private bool _canDoWork; // binding to Switch button
[RelayCommand(CanExecute = nameof(CanDoWork))]
private static void DoWork() // binding to 'Click me' button
{
Debug.WriteLine("DoWork");
}
} |
@drasticactions Thanks! In my sample I did forget to set |
I'm glad you solved it! I'm also pleased that |
Description
This issue has been mentioned but not resolved.
Similar issues, See:
In my case I use Android/MvvmToolkit,
[RelayCommand(CanExecute = nameof(IsValidForm))]
, if IsValidForm(ObservableProperty) is initially true, the button is clickable, if false, the button is not clickable, and changes to the value of IsValidForm don't change the state of the button (not the visual style, but the clickability).Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: