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

Button doesn't disable if the command is set #815

Closed
Blener opened this issue Nov 17, 2020 · 2 comments
Closed

Button doesn't disable if the command is set #815

Blener opened this issue Nov 17, 2020 · 2 comments

Comments

@Blener
Copy link

Blener commented Nov 17, 2020

When a button has the command property set it doesn't get disabled.

let view (model: Model) (dispatch: Msg -> unit) =
        View.ContentPage(
          content = View.StackLayout(padding = Thickness 20.0, verticalOptions = LayoutOptions.Center,
            children = [
                View.Button(text = "Disabled with command", isEnabled = false, command = ignore)
                View.Button(text = "Disabled without command", isEnabled = false)
            ]))

The code above generates this:
image

This was using Fabulous 0.57.0 on an Android emulator.

Thanks.

@TimLariviere
Copy link
Member

@Blener Hi. Thanks for the report, but it's the default behavior of Xamarin.Forms.

A command comes with its own CanExecute property that overrides IsEnabled. If not explicitly set through commandCanExecute, it will default to true so the button will always be active regardless of isEnabled.

So when using commands in Fabulous, use commandCanExecute to switch between enable and disable instead of IsEnabled.

View.Button(text = "Disabled with command", command = ignore, commandCanExecute = false)

@Blener
Copy link
Author

Blener commented Nov 17, 2020

Hi @TimLariviere . My mistake then, sorry for that. Thank you for the help.

@Blener Blener closed this as completed Nov 17, 2020
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