CommunityToolkit
CommunityToolkit copied to clipboard
CanExecute is always false on RelayCommand with enum parameter
public enum MainMenuOption
{
None = 0,
Notifications = 1,
Accounts = 2,
Settings = 3,
Exit = 4,
}
public IRelayCommand ChooseMainMenuCommand { get; init; }
private void ChooseMainMenuCommandImplementation(MainMenuOption option) {...}
ChooseMainMenuCommand = new RelayCommand<MainMenuOption>(ChooseMainMenuCommandImplementation);
This button is always disabled:
xmlns:enums="clr-namespace:Project.Enums"
<Button x:Name="xButton"
Command="{Binding ChooseMainMenuCommand}">
<Button.CommandParameter>
<enums:MainMenuOption>Notifications</enums:MainMenuOption>
</Button.CommandParameter>
</Button>
It runs well if I make the parameter optional: MainMenuOption?
It doesn't work for decimal either, and possibly for other struct types.