Skip to content
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

MAUI Button IsEnabled Binding #372

Closed
1 of 14 tasks
pouchbunny opened this issue Aug 9, 2022 · 9 comments
Closed
1 of 14 tasks

MAUI Button IsEnabled Binding #372

pouchbunny opened this issue Aug 9, 2022 · 9 comments
Labels
external ⤴️ Something related to or caused by an external project mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@pouchbunny
Copy link

Describe the bug

I started noticing my buttons acting weirdly when trying to disable via bindings where in my current project even after setting IsEnabled binding value to false I can still click the button and fire off the binding command.

I created a new app to test and found out that despite when the app first starts and the binding is false, the button can still be clicked until I set it true, then back to false. Only then will it start acting as it should.

IMAGES:

  1. When started - original button is enabled despite CanClick is false
  2. Button clicked and breakpoint fires
  3. Continued and yellow box shows CanClick is still false
  4. Clicked Enable Counter twice (first time to set CanClick to true, then to false) Clicked button not disabled

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

1. New Maui App
2. Add CommunityToolKit
3. Add viewmodel and BindingContext and DataTypes to xaml and xaml.cs
4. Add bindings (can set the bool CanClick binding false in [ObservableProperty] or in constructor but no effect as CanClick is still false when starting app)
5. Add [RelayCommands] to both buttons and set break point on original's RelayCommand
6. Add new button to CanClick = !CanClick (to turn the original button on and off)
7. Run app
8. Click original button and breakpoint will fire

Expected behavior

The original button should be disable from the start as the binding CanClick is initially set to false

Screenshots

image
image
image
image

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

Version 10.0.19044 Build 19044

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

17.3.0 Preview 3.0

Device form factor

Desktop

Nuget packages

image

Additional context

No response

Help us help you

No.

@pouchbunny pouchbunny added the bug 🐛 An unexpected issue that highlights incorrect behavior label Aug 9, 2022
@ghost ghost added the needs triage 🔍 This issue is awaiting triage by maintainers label Aug 9, 2022
@ghost
Copy link

ghost commented Aug 9, 2022

Hello pouchbunny, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@michael-hawker michael-hawker transferred this issue from CommunityToolkit/WindowsCommunityToolkit Aug 9, 2022
@pouchbunny
Copy link
Author

As a follow up. In my own app I created a button to change the value of the binding of one of my buttons that's not being disabled from the start as it should. With the new button it acts just like what I described above. I can officially enable and disable my save button by changing the binding value with the new RelayCommand attached to the new button.

@Ahmadmansoor
Copy link

Ahmadmansoor commented Aug 14, 2022

Yes, it's a big issue, I am struggling for over 1 week thinking my code has the problem. then I read this here which is the same as my issue.
I have 2 buttons both of them are getting value by the binding first one is always true whatever I do except I set the value to the same binding value of the second button.
image

really I begin to believe that CommunityToolkit and DotNet Maui are very buggy and it needs a long time to be stable, which pushes us to move to other languages, really sorry to say that.

@Sergio0694
Copy link
Member

Sergio0694 commented Aug 14, 2022

"really I begin to believe that CommunityToolkit and DotNet Maui are very buggy and it needs a long time to be stable"

You haven't demonstrated that this is in fact a bug in the MVVM Toolkit whatsoever yet. As far as I can see, it's not.

It might be a bug in MAUI, yes, and for that this is the wrong repo. Have you opened an issue on the MAUI repo too?
Also can you provide a minimal repro? We can't just take 10 screenshots of code to investigate.

@Ahmadmansoor
Copy link

@Sergio0694 I think u have your point, but really it is disappoint us when we face simple issues that should not exist or miss essential features.
On the other hand, sharing our code for some private software is not easy as well too, I hope u understand the situation.
anyway a big thanks to the contributor for their great work, and I am sorry if I show a misunderstanding.

@Ahmadmansoor
Copy link

to be more silicification, my problem is the button can't disable itself from the C# code.
and sometimes from the other buttons as well.

@mvervoort
Copy link

It seems as as long the command method with the [RelayCommand] is synchronous, all works fine. When using an Async command, the button stays gray after the first click (although it's clickable as expected). Only on Windows, not in Android.

@Sergio0694
Copy link
Member

Closing this, as it just seems like an issue with MAUI (also I think I've seen this being mentioned in a separate issue as well though I don't have it handy right now). I'd recommend opening an issue in the MAUI repo (or finding one if it already exists) and possibly linking this one there for reference 🙂

@Sergio0694 Sergio0694 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 18, 2022
@Sergio0694 Sergio0694 added external ⤴️ Something related to or caused by an external project mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit and removed bug 🐛 An unexpected issue that highlights incorrect behavior needs triage 🔍 This issue is awaiting triage by maintainers labels Dec 18, 2022
@heartacker
Copy link

move to maui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external ⤴️ Something related to or caused by an external project mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

No branches or pull requests

5 participants