Button visual state looks disabled after invoking bound command

Nick 21 Reputation points
2022-08-27T09:22:12.457+00:00

I have a sample application demonstrating my problem,

https://github.com/NickDevoctomy/MauiMvvmShellPoc

  1. Launch Application
  2. Click on 'Pets' button
  3. Click burger menu (top left)
  4. Click on large 'Home' button at top of flyout
  5. Observe 'Pets' button is now grey
  6. Click burger menu (top left)
  7. Observe 'Home' button is now grey

For some reason this only happens with buttons that are bound to a command, even though for 'Pets' button I am forcing CanExecute to true in the callback.

What I expect should happen is that the buttons should return to their original state. You can test a normal button by clicking the 'Pets click' button instead, this is bound via a click event and thus returns to its original state after being clicked.

Any idea how to fix this? The project is setup as Mvvm using the Community Toolkit, so nothing particularly special going on.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,579 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Nick 21 Reputation points
    2022-08-27T11:29:46.87+00:00

    Okay I have found the fix for now. It's caused by using Community Toolkit IAsyncRelayCommand, I changed it to ICommand and now the button doesn't enter the disabled state, so I've probably missed something in the sample app on how to use that correctly.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.