CommunityToolkit / CommunityToolkit/MVVM-Samples
RelayCommand disables the button
- Dominant language
- No language data
- Stars
- 1.4k
- Forks
- 265
- PR merge metrics
- No merged PRs in 30d
Description
Creating a dynamic buttons in code behind makes the button disabled when the RelayCommand is used.
Here is a example
var removeButton = new Button()
{
Content = "X",
Command = new RelayCommand(RemoveEntry),
CommandParameter = index,
};
then afterwards adding this button to a StackPanel the property isEnabled is always false (no matter how it's bound).
There is a workaround solution make it work
First object initialize the button with IsEnabled =true, without setting the command
var removeButton = new Button()
{
Content = "X",
IsEnabled = true,
CommandParameter = index,
};
afterwards just set the command
removeButton.Command = new RelayCommand(RemoveEntry);
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.