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

[ToolbarItem] IsEnabled property false not working #13257

Open
Strypper opened this issue Feb 10, 2023 · 10 comments
Open

[ToolbarItem] IsEnabled property false not working #13257

Strypper opened this issue Feb 10, 2023 · 10 comments
Labels
area-controls-toolbar ToolBar platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Strypper
Copy link

Description

The button bar is not disable when set IsEnable to false

Steps to Reproduce

<app:BasePage.ToolbarItems>
        <ToolbarItem
            Command="{x:Binding OpenUrlCommand}"
            CommandParameter="{x:Binding ControlGroup.MicrosoftStoreLink}"
            IconImageSource="{x:StaticResource MicrosoftStoreIcon}"
            IsEnabled="False"
            Text="Source code" />
        <ToolbarItem
            Command="{x:Binding OpenUrlCommand}"
            CommandParameter="{x:Binding ControlGroup.ProviderUrl}"
            IconImageSource="{x:StaticResource InfoIcon}"
            Text="Original Document" />
    </app:BasePage.ToolbarItems>

Link to public reproduction project repository

https://github.com/Strypper/mauisland

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Windows 11 - Android 12

Did you find any workaround?

No

Relevant log output

None
@Strypper Strypper added the t/bug Something isn't working label Feb 10, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Feb 13, 2023
@ghost
Copy link

ghost commented Feb 13, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@Laim
Copy link

Laim commented Feb 20, 2023

I am seeing this same issue (.NET 6), setting it to False doesn't seem to disable it.

@Strypper
Copy link
Author

This also happen on Windows, I don't have a mac device to test on IOS and Catalyst

@AlexeyStarkov
Copy link

AlexeyStarkov commented Feb 26, 2023

Facing a similar issue: the Button control with "False" value assigned to IsEnabled stays enabled after startup.

@Laim
Copy link

Laim commented Mar 11, 2023

System.InvalidOperationException:“The BindableProperty "IsEnabled" is readonly.”


        <MenuBarItem Text="Locations">

            <MenuFlyoutItem

                Command="{Binding AddLocationCommand}"

                IsEnabled="false"

                Text="Add Location" />

        </MenuBarItem>

image

Direct crash, read only?

However, the document and code both display {get; set;}.

Is MAUI a toy? Can't complete any complicated work. The response to the problem and the update speed are extremely slow, which is really frustrating.

Are you getting a crash when it's set to False? For me it just stays enabled but doesn't crash

@jinxinjuan jinxinjuan added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Jun 9, 2023
@jbtdevgit
Copy link

jbtdevgit commented Sep 22, 2023

I checked the code and I believe the IsEnabled is not included yet, though it is weird that they put a property that is not implemented yet. I have a workaround for this if you want to disable it, but pretty limited since you cannot do a binding on it. All you have to do in your RelayCommand where the toolbar item is binded is to add a parameter to it.

[RelayCommand]
private void YourButton(string unecessaryParam)
{}

This should disable the toolbar

@kimhongka
Copy link

I'm getting the same issue.
According to MAUI document, I can see they want to use CanExecute in Commanding to enable/disable the toolbarItem.
Screenshot 2024-01-05 at 9 19 44 am

I have followed it and it works as it expected (it greyed out when it's disabled) for iOS, however it does not grey out for Android. Functionally, it's disabled, the function of the toolbaritem disabled, but the text colour is still showing as white.

i.e In Android only, CanExcute property

  1. initial setting the property as false(greyed out and function not available) - worked
  2. from false to true (changed the colour back to white and function available) - worked
  3. from true to false (text colour remained white and function not available) - not working for the Text colour

I've tried to use IsEnabled property binding way, the behaviour is the same.

I think somewhere in MAUI, it dose not raise the property change for isEnabled or ChangeCanExecute when it set to false.

This issue should be fixed.

@ao1010
Copy link

ao1010 commented May 29, 2024

I cannot believe something so fundamental to most Android apps is still broken a year later after being reported.

Xamarin Forms is no longer supported so we don't have much of a choice but to move to MAUI.

These kinds of issues make for a really poor experience from an end users perspective who want to see improvements not the introduction of useability issues.

Is this likely to be fixed or do I need to look for other options?

@Flais
Copy link

Flais commented Jul 11, 2024

I'm getting the same issue. According to MAUI document, I can see they want to use CanExecute in Commanding to enable/disable the toolbarItem. Screenshot 2024-01-05 at 9 19 44 am

I have followed it and it works as it expected (it greyed out when it's disabled) for iOS, however it does not grey out for Android. Functionally, it's disabled, the function of the toolbaritem disabled, but the text colour is still showing as white.

i.e In Android only, CanExcute property

  1. initial setting the property as false(greyed out and function not available) - worked
  2. from false to true (changed the colour back to white and function available) - worked
  3. from true to false (text colour remained white and function not available) - not working for the Text colour

I've tried to use IsEnabled property binding way, the behaviour is the same.

I think somewhere in MAUI, it dose not raise the property change for isEnabled or ChangeCanExecute when it set to false.

This issue should be fixed.

Hello @kimhongka, thanks you very much for your post. I work with iOS and will try this.
For your Problem with Android: Did you try a DataTrigger for setting the text colour, bound to the same property like can execute?

Best regards

@Flais
Copy link

Flais commented Aug 8, 2024

On iOS I got it to work with CanExecute. I also had trubble with changes of CanExecute not effecting the enabled state. Here is my solution:

// these are the two commands for the ToolbarItems. Do not declare it as ICommand.
public AsyncRelayCommand OpenEquipmentHistoryCommand { get; private set; }
public AsyncRelayCommand OpenRepairSignatureCommand { get; private set; } 

// somewhere initialize the commands (maybe in constructor) with CanExecute
OpenEquipmentHistoryCommand =
    new AsyncRelayCommand(CallEquipmentHistoryCommandOfEquipmentOverviewViewModel,
        () => IsEquipmentViewActive);

OpenRepairSignatureCommand =
    new AsyncRelayCommand(CallRepairSignatureCommandOfCalibrationViewModel,
        () => IsCalibrationViewActive);

// at all places the CanExecute condition changes you have to call NotifyCanExecuteChanged of the command.
// this results in refetching the result of CanExecute and changes enabled state
IsCalibrationViewActive = false;
IsEquipmentViewActive = true;
OpenEquipmentHistoryCommand.NotifyCanExecuteChanged();
OpenRepairSignatureCommand.NotifyCanExecuteChanged();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-toolbar ToolBar platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants