dotnet/maui

Android: Binding does not work when view is hidden

jbe2277 opened this issue · 7 comments

Description

On Android it seems that the Binding does not update the properties when the view is hidden. However, it works on Windows and it worked with Xamarin Forms 5 on Android as well.

Explanation: During navigation (async Task operation) the navigation item is shown as disabled (gray). After navigation has completed the NavigationItem.IsCommandEnabled is set back to true and via Binding the navigation items is shown as enabled again.

Issue on Android:
maui-android-issue02

On Windows this works correct:
maui-windows-works02

Steps to Reproduce

Link to public reproduction project repository

https://github.com/jbe2277/waf/tree/69803cef490970a344c370616021464f59ae201d

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No

Relevant log output

No response

if you add a color for "Isenabled=true" does that work?

  <Label Grid.RowSpan="2" Text="{Binding IconGlyph}" FontFamily="MaterialIcons" FontSize="22" VerticalOptions="Center" HorizontalOptions="Center">
                                <Label.Triggers>
                                    <DataTrigger TargetType="Label" Binding="{Binding IsCommandEnabled}" Value="False">
                                        <Setter Property="TextColor" Value="LightGray"/>
                                    </DataTrigger>
                                </Label.Triggers>
                            </Label>

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.

@PureWeen : I have added an additional DataTrigger with color Red for true. This works. After navigation has completed it applies the color Red.

So it seems that it does not switch back to the default color when the DataTrigger condition changes to false. However, this issue is only on Android. Windows works correct.

<Label Grid.Column="1" Grid.Row="0" Text="{Binding Title}" Style="{StaticResource Subtitle}" VerticalOptions="Center">
    <Label.Triggers>
        <DataTrigger TargetType="Label" Binding="{Binding IsCommandEnabled}" Value="False">
            <Setter Property="TextColor" Value="LightGray"/>
        </DataTrigger>
        <DataTrigger TargetType="Label" Binding="{Binding IsCommandEnabled}" Value="True">
            <Setter Property="TextColor" Value="Red"/>
        </DataTrigger>
    </Label.Triggers>
</Label>

Update: This issue still exists after update to .NET 7/MAUI 7.