Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PopToRootAsync到选定的Shell弹出型按钮项_C#_Xaml_Xamarin.forms_Navigation - Fatal编程技术网

C# PopToRootAsync到选定的Shell弹出型按钮项

C# PopToRootAsync到选定的Shell弹出型按钮项,c#,xaml,xamarin.forms,navigation,C#,Xaml,Xamarin.forms,Navigation,下面的代码使用创建了一个带有集成侧栏的操作栏,这样用户可以通过向右滑动轻松导航。作为C#的新手,我知道当应用程序打开时,第一个shell内容将是加载和预览的页面,即ContentTemplate=“{DataTemplate local:LoanHistory}” 我也理解,当您单击弹出式按钮时,您不会将堆栈添加到导航中,但每次单击时,都会更改内容。下面的代码位于名为MainPage.xaml的文件中 <?xml version="1.0" encoding="utf-8" ?> &

下面的代码使用
创建了一个带有集成侧栏的操作栏,这样用户可以通过向右滑动轻松导航。作为C#的新手,我知道当应用程序打开时,第一个shell内容将是
加载和预览的页面,即
ContentTemplate=“{DataTemplate local:LoanHistory}”

我也理解,当您单击弹出式按钮时,您不会将堆栈添加到导航中,但每次单击时,
都会更改内容。下面的代码位于名为MainPage.xaml的文件中

<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:LoanApp2.Views"
             mc:Ignorable="d"
             x:Class="LoanApp2.MainPage" BackgroundColor="#62bef0" Title="Dylan">

    <FlyoutItem Title="MyTabApp" Shell.TabBarIsVisible="False" FlyoutDisplayOptions="AsMultipleItems">

        <ShellContent Title="Loan History" IsTabStop="False" ContentTemplate="{DataTemplate local:LoanHistory}"/>
        <ShellContent Title="Apply for Loan" IsTabStop="False" ContentTemplate="{DataTemplate local:LoanApplication}"/>
        <ShellContent Title="Logout" IsTabStop="False"  ContentTemplate="{DataTemplate local:LoanHistory}"/>
    </FlyoutItem>

</Shell>

因此,通过侧栏(shell),我单击Apply for Loan,这会将我带到
LoanApplication.xaml
。此时,导航中没有添加堆栈。在
LoanApplication.xaml
中,我使用绑定到按钮的
PushAsync
进入名为
AmountLoanable.xaml
的页面。这将添加到堆栈中,操作栏上的“后退”按钮现在可用


在我处理完
AmountLoanable.xaml
上的内容后,我使用
PopToRootAsync
删除除根页面之外的导航堆栈(根页面是
MainPage.xaml
)。然而,它把我带回了之前选择的“申请贷款”,我希望它加载一个新的
MainPage.xaml
页面。这样,第一页(贷款历史记录)将被选中,而不是通过
访问的最后一页。请尝试将
应用程序.Current.MainPage
重置为默认Shell,例如:
应用程序.Current.MainPage=new AppShell()

乐意帮忙=)