Share via

MAUI Label randomly appearing and disappearing in iOS

Jai Holloway 110 Reputation points
2026-05-28T11:45:09.0566667+00:00

Hi there

I have an if statement that sets the visible property of a label to false if there is no value or it is 0. But I have checked the result from the api and there definitely is a value. The behaviour is inconsistent. Sometimes when I navigate to the item then navigate back, it shows the label. The I repeat and the label disappears. It works consistently in android, but not ios

Developer technologies | .NET | .NET Multi-platform App UI
0 comments No comments

2 answers

Sort by: Most helpful
  1. Michael Le (WICLOUD CORPORATION) 11,325 Reputation points Microsoft External Staff Moderator
    2026-05-29T03:11:48.43+00:00

    Hello @Jai Holloway ,

    From what you have described, I imagine you are likely setting IsVisible directly in code-behind instead of binding it to a ViewModel property that fires INotifyPropertyChanged. iOS is not forgiving about when it re-renders, so if you have something like this:

    if (apiValue == 0)
        myLabel.IsVisible = false;
    

    This would create a race condition.

    Using a proper binding and making sure to raise PropertyChanged when the value changes should resolve the issue. For example:

    private bool _showLabel;
    public bool ShowLabel
    {
        get => _showLabel;
        set
        {
            _showLabel = value;
            OnPropertyChanged();
        }
    }
    

    And then in your XAML:

    <Label IsVisible="{Binding ShowLabel}" />
    

    I would also appreciate if you could share the relevant code snippets or more details about your implementation in future questions, to prevent any misunderstandings and to provide you with the most accurate assistance.

    If this response was informative, I would be grateful if you could leave your confirmation following the instructions provided in this guide.

    Thank you.

    Was this answer helpful?


  2. AI answer

    2026-05-28T11:45:27.2766667+00:00

    On iOS, visual elements can behave differently from Android due to platform-specific layout and lifecycle differences. A Label is a View that displays text and its visibility is controlled by properties such as IsVisible and by how the layout measures and arranges it.

    Given the symptoms (intermittent visibility, fixed by navigating away/back, Android working fine), likely causes include:

    1. Platform-specific layout/measure timing
      iOS may be measuring or arranging the page at a time when the bound value is not yet set, or when the binding context changes later. If the IsVisible property is bound to a value that updates after the initial layout pass, the label may not re-measure correctly unless the layout is invalidated.
    2. Binding or value conversion issues
      If the IsVisible is bound to a value derived from the API result (e.g., via a converter or computed property), ensure:
      • The property raises PropertyChanged correctly whenever the API result changes.
      • The converter returns a deterministic bool for all possible values (including null or default values).
    3. Navigation and page reuse
      When navigating back and forth, the same page instance may be reused, and iOS can re-apply layout differently than Android. If the visibility logic runs only once (e.g., in the constructor or OnAppearing without re-evaluating the latest data), the label may end up with stale visibility state.

    To stabilize behavior on iOS:

    1. Bind IsVisible to a view-model property rather than setting it directly in code-behind if statements, and ensure INotifyPropertyChanged is implemented correctly.
    2. Force layout refresh when the API data arrives: after updating the bound property, call InvalidateMeasure or ForceLayout on the parent layout or page so iOS re-measures and re-arranges the label.
    3. Avoid relying on initial layout only: ensure the visibility logic is re-evaluated whenever the API data changes or when the page appears again (e.g., in OnAppearing), not just once in the constructor.
    4. Check for value edge cases: confirm that the API value is not sometimes 0, null, or an empty string on iOS due to serialization or culture differences, and that the visibility condition handles all of these consistently.

    These steps align with how MAUI views like Label participate in layout and measurement across platforms, and help eliminate platform-specific timing issues that can cause intermittent visibility.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.