Forum Xamarin.Forms

Setting Detail of Master Detail page causes flickering

HamsterHamster RSMember ✭✭

I'm trying to prevent flickering from happening when I change the Detail in MasterDetailPage.

In the constructor of the page I create all the required pages like so :
aboutPage = new NavigationPage(new Pages.About());

And then in the Clicked event I set the Detail to one of those instances:
Detail = aboutPage;
IsPresented = false;

This results in screen becoming completely white for a second, including the header, before pages show up.

How can I fix or mend this?



  • LandLuLandLu Member, Xamarin Team Xamurai

    Can you provide some screenshots and code to specify your issues?

  • HamsterHamster RSMember ✭✭
    edited April 2019

    Sure thing @LandLu !

    This is cleared up code from the app :

    Drawer.xaml :

                <ContentPage Title="Master" Icon="hamburger.png">
                    <!--Padding="10" BackgroundColor="Gray" Title="Master">-->
                            <StackLayout BackgroundColor="#EDEDED"> <!--Margin="5,30,5,5"-->                       
                                <Button Text="{Binding Drawer_Settings}" BackgroundColor="#EDEDED" Clicked="btnSettings_Clicked"></Button>

    Drawer.xaml.cs :

      public partial class Drawer : MasterDetailPage
            NavigationPage settingsPage;
        NavigationPage mainScreen;
            public Drawer()
                this.BindingContext = Storage.AppLanguage;
                mainScreen = new NavigationPage(new MainPage());
                Detail = mainScreen;
                IsPresented = false;
                settingsPage = new NavigationPage(new Pages.Settings());
            private  async void btnSettings_Clicked(object sender, EventArgs e)
                IsPresented = false;
                await Task.Run(() =>
                    Device.BeginInvokeOnMainThread(() =>
                        Detail = settingsPage;

    I delay task by 300ms because otherwise the Flyout drawer "lags" as the new page loads. But even in that case, I can see the page becoming white before the new page loads up.

    It could be useful stating that this project started as a Blank project template.

    Here's what the lag looks like :

    I already tested various options, for example using Page Activator, or running on another thread.

    What am I doing wrong and how can I fix it? We're scheduled to release next month and could use some help with this :)

    Thanks !

    Xamarin Designer
    Xamarin Templates 16.1.47
    Xamarin.Android SDK -
    Xamarin.IOS and Xamarin.Mac SDK -
    XamlCompilation is enabled like so :
    [assembly: XamlCompilation(XamlCompilationOptions.Compile)]

  • LandLuLandLu Member, Xamarin Team Xamurai

    For the Android side, it does show a blank page first then render your destination page. So the template master-detail page will set a delay before displaying the new page:

    Detail = settingsPage;
    if (Device.RuntimePlatform == Device.Android)
                        await Task.Delay(100);
    IsPresented = false;

    This delay time could be set to a larger value if your destination page has lots of elements to be loaded.

  • HamsterHamster RSMember ✭✭

    Sadly the result is still affecting the user experience.

    I got some great workaround recommendations via Support ticket.
    One of them is to have only one Detail page and change its content based on what user requests.

    I converted my ContentPages to ContentViews and followed the recommendation.

    This workaround is really fast and snappy with less complex "pages".

    The other workaround was to instantiate new drawer with set Detail. This also works and avoids the white screen, however it's a bit slower compared to using ContentView instances.

    From what I understand, the support member has identified this as a bug as well. If that's the case I hope it will be fixed soon, as content views don't allow usage of built in page layouts, such as Tabbed View.

  • TaylorDTaylorD USMember ✭✭✭

    What version of the Xamarin.Forms NuGet package are you using? This used to be an issue before one of the 3.x updates. Make sure you are updated to the latest version of XF.

  • HamsterHamster RSMember ✭✭

    I have installed. It came as default with Visual Studio 2019 installation I believe.

  • ledragonledragon Member ✭✭✭
    edited October 2019

    @Hamster Hi there,

    Did you get anywhere towards improving the UI experience for this. I'm experiencing the same issue. My Detail Pages are quite complex and loading is causing jerkiness on navigaton and the white screen to appear

Sign In or Register to comment.