Skip to content

[BUG] StatusBarBehavior does not calculate correct height according to .NET 10 #2988

Closed

Description

@kerberosargos

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Hello,
I have migrated my project .Net 10 and MCT 13. After that I'm having problems after the migration related this issue is it related about MCT or MAUI .NET 10?

Thank you in advance

Expected Behavior

The white line between the Statusbar and Title content should not be visible.

Steps To Reproduce

NavBarIssue-Kerberos.zip

Link to public reproduction project repository

.NET 10 MAUI

Environment

- .NET MAUI CommunityToolkit:  13.0
- OS: Windows VS 2026 + iOS
- .NET MAUI: 10.0.11

Anything else?

Image

Activity

  1. kerberosargos commented on Dec 5, 2025

    @kerberosargos
    Author

    Hello again,

    I found the source of the problem.

    That is not related about MAUI that is related about MAUI Community Toolkit's StatusBarBehavior.shared.cs file

    This code returns incorrect results and the height value of the statusbar is calculated incorrectly.

    Orginal code line

    ...
    #if IOS
    			StatusBar.SetBarSize(Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page.GetUseSafeArea(page));
    #endif
    ...
    

    It must be like as following

    ...
    #if IOS
        bool isUsingSafeArea = false;
    
        var edges = page.SafeAreaEdges;
        if (edges.Top != SafeAreaRegions.None)
        {
            isUsingSafeArea = true;
        }
    
        StatusBar.SetBarSize(isUsingSafeArea);
    
    #endif
    ...
    

    Result

    Image
  2. changed the title [-][BUG] is this related about MCT[/-] [+][BUG] StatusBarBehavior does not calculate correct height according to .NET 10[/+] on Dec 5, 2025
  3. kerberosargos commented on Dec 8, 2025

    @kerberosargos
    Author

    Hello again. My temporary solution as following

    using CommunityToolkit.Maui.Behaviors;
    using CommunityToolkit.Maui.Core.Platform;
    
    namespace YourNameSpace.Behaviors;
    
    public class StatusBarBehaviorFix : StatusBarBehavior
    {
    #if !(WINDOWS || MACCATALYST || TIZEN)
    
    #if IOS
        protected override void OnAttachedTo(Page page, UIKit.UIView platformView)
    #elif ANDROID
    	protected override void OnAttachedTo(Page page, Android.Views.View platformView)
    #else
    	protected override void OnAttachedTo(Page page, object platformView)
    #endif
        {
            base.OnAttachedTo(page, platformView);
    
            if (ApplyOn is StatusBarApplyOn.OnBehaviorAttachedTo)
            {
    #if IOS
                StatusBar.SetBarSize(isUsingSafeArea: isUsingSafeArea(page));
    #endif
    
                StatusBar.SetColor(StatusBarColor);
                StatusBar.SetStyle(StatusBarStyle);
            }
    
            page.NavigatedTo += OnPageNavigatedTo;
    #if IOS
            page.SizeChanged += OnPageSizeChanged;
    #endif
        }
    
    #if IOS
        protected override void OnDetachedFrom(Page page, UIKit.UIView platformView)
    #elif ANDROID
    	protected override void OnDetachedFrom(Page page, Android.Views.View platformView)
    #else
    	protected override void OnDetachedFrom(Page page, object platformView)
    #endif
        {
    #if IOS
            page.SizeChanged -= OnPageSizeChanged;
    #endif
            base.OnDetachedFrom(page, platformView);
    
            page.NavigatedTo -= OnPageNavigatedTo;
        }
    
    #if IOS
        static void OnPageSizeChanged(object? sender, EventArgs e)
        {
            ArgumentNullException.ThrowIfNull(sender);
            StatusBar.SetBarSize(isUsingSafeArea: isUsingSafeArea((Page)sender));
        }
    #endif
    
        void OnPageNavigatedTo(object? sender, NavigatedToEventArgs e)
        {
            if (ApplyOn is StatusBarApplyOn.OnPageNavigatedTo)
            {
                StatusBar.SetColor(StatusBarColor);
                StatusBar.SetStyle(StatusBarStyle);
            }
        }
    
    #endif
    
        static bool isUsingSafeArea(Page page)
        {
            bool isUsingSafeArea = false;
    
            if (page is ContentPage contentPage)
            {
                var edges = contentPage.SafeAreaEdges;
                if (edges.Top != SafeAreaRegions.None)
                {
                    isUsingSafeArea = true;
                }
    
            }
            return isUsingSafeArea;
        }
    }
    
  4. LeoJHarris commented on Dec 17, 2025

    @LeoJHarris

    @kerberosargos good find! We lso noticing the same problem, a few issues we are waiting to get resolved in the library, h9ope they come soon. Thanks MAUI team!

  5. KevThompson2020 commented on Jan 26, 2026

    @KevThompson2020

    we have been hit by this since .net8 so good find on a work around kerberosargos

  6. locked and limited conversation to collaborators on Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions