本文介绍了[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
解决方案
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"
解决方案
这篇关于[UWP]如果NavigationCacheMode已启用,NavigationView不响应。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!