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

RelayCommand disables the button #103

Open
zoranivoclar opened this issue Oct 6, 2022 · 1 comment
Open

RelayCommand disables the button #103

zoranivoclar opened this issue Oct 6, 2022 · 1 comment

Comments

@zoranivoclar
Copy link

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<int>(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<int>(RemoveEntry);
@PeskovV
Copy link

PeskovV commented Dec 22, 2022

Hi!
I have the same issue

I think you should ask question here https://github.com/CommunityToolkit/dotnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants