-
Notifications
You must be signed in to change notification settings - Fork 1.9k
The command interface for buttons - Command.ChangeCanExecute() #9419
Copy link
Copy link
Closed
Labels
area-controls-buttonButton, ImageButtonButton, ImageButtonplatform/windowss/needs-attentionIssue has more information and needs another lookIssue has more information and needs another lookt/bugSomething isn't workingSomething isn't working
Description
The method call Command.ChangeCanExecute() is explained in the introduced in the guide for buttons in MAUI - link is shown below.
https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/button#use-the-command-interface
When you use the code right above the title "Press and release the button".
MultiplyBy2Command = new Command(
execute: () =>
{
Number *= 2;
((Command)MultiplyBy2Command).ChangeCanExecute();
((Command)DivideBy2Command).ChangeCanExecute();
},
canExecute: () => Number < Math.Pow(2, 10));
DivideBy2Command = new Command(
execute: () =>
{
Number /= 2;
((Command)MultiplyBy2Command).ChangeCanExecute();
((Command)DivideBy2Command).ChangeCanExecute();
},
canExecute: () => Number > Math.Pow(2, -10));The app is in Windows showing a fine blue button, that changes color from blue to gray, when it reaches the limit.
When you leave the limit again, the button do not change the color, but it is again clickable.
If you reach, the upper limit, and afterwards the lower limit, both buttons are gray, as shown on the picture below.

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-controls-buttonButton, ImageButtonButton, ImageButtonplatform/windowss/needs-attentionIssue has more information and needs another lookIssue has more information and needs another lookt/bugSomething isn't workingSomething isn't working