How to improve app performance when clicking hamburger menu items in UWP?

Kirankumar Maharana 86 Reputation points
2021-05-22T17:01:08.797+00:00

Hi Team,

I'm using Template 10 for the MVVM and the Hamburger menu in my UWP application. Normally from page to page navigation takes 2 to 3 secs. When App is in the background for more than 5 hours, then come back to the foreground, and page navigation takes 8 sec. How can I reduce the delay from page to page navigation.

XAML code for Menu Item:

<Controls:HamburgerButtonInfo ClearHistory="True" x:Name="manifest" Selected="manifest_Selected" Unselected="manifest_Unselected" PageType="views:Manifest"> <StackPanel Orientation="Horizontal"> <BitmapIcon Width="30" Height="30" x:Name="manifesticon" Margin="10,20,0,0" UriSource="ms-appx:///Assets/ic_menu_manifest.png"/> <TextBlock Margin="16,20,0,0" x:Name="manifesttext" VerticalAlignment="Center" Text="Manifest" /> </StackPanel> </Controls:HamburgerButtonInfo>

CS code:

public void manifest_Selected(object sender, RoutedEventArgs e)
{
    reportElement = new HamburgerButtonInfo();
    manifesticon.Foreground = (Brush)Application.Current.Resources["HeaderBackground"];
    manifesttext.Foreground = (Brush)Application.Current.Resources["HeaderBackground"];
    reportElement = manifest;
    if (report.IsEnabled)
    {
        report_Unselected(sender, e);
    }
}

public void manifest_Unselected(object sender, RoutedEventArgs e)
{
    manifesticon.Foreground = new SolidColorBrush(Color.FromArgb(255, 229, 229, 229));
    manifesttext.Foreground = new SolidColorBrush(Color.FromArgb(255, 229, 229, 229));
}
Developer technologies Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. AryaDing-MSFT 2,916 Reputation points
    2021-05-24T07:53:47.523+00:00

    Hi,

    Welcome to Microsoft Q&A!

    If you make your app in the background for a long time, it will definitely affect the navigation speed. Besides, it is recommended to use NavigationView to switch pages than Hamburger menu, which is more advanced. As follows:

    Xaml code:

    <Page  
       ..>  
       
        <Grid>  
            <NavigationView PaneDisplayMode="Left"  ItemInvoked="NavigationView_ItemInvoked">  
                <NavigationView.MenuItems >  
                    <NavigationViewItem Content="A" x:Name="A" />  
                    <NavigationViewItem Content="B" x:Name="B" />               
                </NavigationView.MenuItems>  
                <Frame x:Name="ContentFrame"/>  
            </NavigationView>  
        </Grid>  
    </Page>  
    

    Code behind:

    private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)  
            {  
                var item = args.InvokedItemContainer;  
                switch (item.Name)  
                {  
                    case "A":  
                        ContentFrame.Navigate(typeof(BlankPage1));  
                        break;  
    case "B":  
                        ContentFrame.Navigate(typeof(BlankPage2));  
                        break;  
      
                }  
            }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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