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

IsEnabled is unable to update visual appearance #13971

Closed
ChristianA1992 opened this issue Mar 15, 2023 · 4 comments
Closed

IsEnabled is unable to update visual appearance #13971

ChristianA1992 opened this issue Mar 15, 2023 · 4 comments
Labels
legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity t/bug Something isn't working

Comments

@ChristianA1992
Copy link

Description

I'm working on a MAUI app, that's currently targeting .net 7.
I have an issue with one of my pages, where data inputs are enabled/disabled depending on data we get from an API.

I navigate to this page, via a relay command, from a CollectionView. It hits the following command:

[RelayCommand]
public async Task GotoDetail(object arg)
{
    var item = arg as ServicePlanListModel;
    await _navigationService.CreateBuilder().AddSegment<ServicePlanDetailPage>().AddParameter("servicePlan", item).NavigateAsync();
}

I hit the OnNavigateTo method in my page:

public override async void OnNavigatedTo(INavigationParameters parameters)

I have an observable property in my ViewModel

 [ObservableProperty]
 private bool _allowEdit;

Which is set in the OnNavigatedTo method.

I have multiple fields in my xaml file like this:

<Picker ItemsSource="{Binding ServiceTypes}" ItemDisplayBinding="{Binding Text}"
                            SelectedItem="{Binding SelectedServiceType}" IsEnabled="{Binding AllowEdit}" />

The binding works fine, and actually does enable and disable them correctly. However the visual state is always as if it's disabled:

image

If i set my _allowEdit to true, the visual appearance will always stay as if it's enabled, even though it might be disabled.

Steps to Reproduce

  1. Create a MAUI app
  2. Setup viewmodel and bindings for a page.
  3. Set IsEnabled to a variable that is controlled by the viewmodel.
  4. Change this variable from the OnNavigatedTo Method (it might be the same in other methods)
  5. See that the visual appearance won't change

Link to public reproduction project repository

I cannot provide this atm

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13

Did you find any workaround?

No response

Relevant log output

No response

@ChristianA1992 ChristianA1992 added the t/bug Something isn't working label Mar 15, 2023
@ChristianA1992
Copy link
Author

I did manage to find a workaround.
So i basically have the same element twice. But I now control IsVisible instead

<Entry Text="{Binding Km}" Keyboard="Numeric" IsVisible="{Binding AllowEdit}"/>
<Entry Text="{Binding Km}" Keyboard="Numeric" IsEnabled="False"
       IsVisible="{Binding AllowEdit, Converter={StaticResource InvertedBoolConverter}}"/>

@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Mar 16, 2023
@ghost
Copy link

ghost commented Mar 16, 2023

Hi @ChristianA1992. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Mar 20, 2023
@ghost
Copy link

ghost commented Mar 20, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Mar 22, 2023
@ghost ghost added s/no-recent-activity Issue has had no recent activity and removed s/no-recent-activity Issue has had no recent activity labels Mar 22, 2023
@ghost
Copy link

ghost commented Mar 27, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@ghost ghost closed this as completed Mar 30, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants