[UWP]如果NavigationCacheMode已启用,NavigationView不响应。 [英] [UWP] NavigationView doesn't respond if NavigationCacheMode is Enabled.

查看:96
本文介绍了[UWP]如果NavigationCacheMode已启用,NavigationView不响应。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SDK target 17763; min 17134;

PC:Win10 1809(17763.316)



代码示例:

XAML:

 


< Page x:Class =" NavigationViewBug.MainPage" 
xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local =" using:NavigationViewBug"
xmlns:d =" http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable =" d"
NavigationCacheMode ="已启用"
Background =" {ThemeResource ApplicationPageBackgroundThemeBrush}">

< Grid>
< NavigationView ItemInvoked =" OnItemInvoked">
< NavigationView.MenuItems>
< NavigationViewItem Content =" Page#1"
Icon =" Page"
Tag =" Page#1" />
< NavigationViewItem Content =" Page#2"
Icon =" Page2"
Tag =" Page#2" />
< NavigationViewItem Content =" Pane#3"
Icon ="取消"
Tag =" Page#3" />
< /NavigationView.MenuItems>

< Frame x:Name =" FrameContent" />

< / NavigationView>
< / Grid>
< / Page>




C#:


   


 private void OnItemInvoked(NavigationView sender,NavigationViewItemInvokedEventArgs args)
{
switch(args.InvokedItemContainer.Tag)
{
case" Page#1":
FrameContent.Navigate(typeof(Page1));
休息;
case" Page#2":
FrameContent.Navigate(typeof(Page2));
休息;
默认值:
Frame.Navigate(typeof(Page3));
休息;
}
}


我可以导航到所有页面。 H 无论如何,w 母鸡Page3调用"Frame.GoBack();",MainPage被加载而NavigationView没有响应。

 

 private void OnBackRequested(object sender,BackRequestedEventArgs e)
{
if(Frame.CanGoBack)
{
Frame.GoBack();
e.Handled = true;
}
}



我无法在PC上重现它:Win10 1803或者NavigationCacheMode ="已禁用>




$
b $ b

解决方案


我可以不使用您提供的代码段在build 1809中重现此问题。您说当从Page3导航回MainPage时,导航视图不响应。但是在我的测试中,当我点击导航的
项目并导航到不同的页面时,导航视图仍然可以响应。


我正在一个空白项目中测试它。你试过在一个明确的项目中测试这个吗?如果你可以在一个空白的应用程序中重现这个问题,你可以分享我的样本。


祝你好运,


Roy


SDK target 17763; min 17134;
PC: Win10 1809 (17763.316)

Code Sample:
XAML:


<Page x:Class="NavigationViewBug.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:NavigationViewBug"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      NavigationCacheMode="Enabled"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <NavigationView ItemInvoked="OnItemInvoked">
            <NavigationView.MenuItems>
                <NavigationViewItem Content="Page #1"
                                         Icon="Page"
                                         Tag="Page #1" />
                <NavigationViewItem Content="Page #2"
                                         Icon="Page2"
                                         Tag="Page #2" />
                <NavigationViewItem Content="Pane #3"
                                         Icon="Cancel"
                                         Tag="Page #3" />
            </NavigationView.MenuItems>

            <Frame x:Name="FrameContent"/>

        </NavigationView>
    </Grid>
</Page>


C#:

private void OnItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
    switch (args.InvokedItemContainer.Tag)
    {
        case "Page #1":
            FrameContent.Navigate(typeof(Page1));
            break;
        case "Page #2":
            FrameContent.Navigate(typeof(Page2));
            break;
        default:
            Frame.Navigate(typeof(Page3));
            break;
    }
}

I can navigate to all pages. However, when Page3 calls "Frame.GoBack();", MainPage is loaded and NavigationView doesn't respond.

        private void OnBackRequested(object sender, BackRequestedEventArgs e)
        {
            if (Frame.CanGoBack)
            {
                Frame.GoBack();
                e.Handled = true;
            }
        }


I can't reproduce it on PC: Win10 1803 or NavigationCacheMode="Disabled"




解决方案

Hi,

I could not reproduce this issue in build 1809 using the code snippet you provide. You said that when navigate back to MainPage from Page3, the navigationview doesn't response. But in my test the navigationview could still response when I click the navigation item and navigate to different pages.

I'm testing this in a blank project. Have you tried to test this in a clear project? If you could reproduce the issue in a blank app, you could share me the sample.

Best regards,

Roy


这篇关于[UWP]如果NavigationCacheMode已启用,NavigationView不响应。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆