Jos*_*rme 5 c# xaml android xamarin.forms xamarin.forms.shell
仅在login和notifications页面上我希望用户无法返回到上一页。在所有其他页面上,该过程可以正常进行。
到目前为止,我只能使用 禁用按钮单击操作BackButtonBehavior IsEnabled = "False"。
NotificationsPage.xaml和LoginPage.xaml
\n<Shell.BackButtonBehavior>\n <BackButtonBehavior IsEnabled="False"/>\n</Shell.BackButtonBehavior>\nRun Code Online (Sandbox Code Playgroud)\n\n令牌视图模型
\nawait Shell.Current.GoToAsync($"{nameof(NotificacoesPage)}");\nRun Code Online (Sandbox Code Playgroud)\n应用程序.xaml.cs
\nawait Shell.Current.GoToAsync($"{nameof(NotificacoesPage)}", false);\nRun Code Online (Sandbox Code Playgroud)\nAppShell.xaml
\n<TabBar>\n <Tab Icon="notificacao_icone.png"\n Title="Notifica\xc3\xa7\xc3\xb5es">\n <ShellContent ContentTemplate="{DataTemplate local:NotificacoesPage}" />\n </Tab>\n\n <Tab Icon="configuracoes_icone.png"\n Title="Configura\xc3\xa7\xc3\xb5es">\n <ShellContent ContentTemplate="{DataTemplate local:ConfiguracoesPage}" />\n </Tab>\n</TabBar>\nRun Code Online (Sandbox Code Playgroud)\nAppShell.xaml.cs
\nRouting.RegisterRoute(nameof(LoginPage), typeof(LoginPage));\nRouting.RegisterRoute(nameof(TokenPage), typeof(TokenPage));\nRouting.RegisterRoute(nameof(NotificacoesPage), typeof(NotificacoesPage));\nRouting.RegisterRoute(nameof(NotificacaoDetalhePage), typeof(NotificacaoDetalhePage));\nRouting.RegisterRoute(nameof(ConfiguracoesPage), typeof(ConfiguracoesPage));\nRun Code Online (Sandbox Code Playgroud)\n
这是一个解决方法。您可以隐藏整个导航栏,然后使用 StackLayout 自定义一个导航栏来代替它。
就像是:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ShellNewDemo.Views.ItemDetailPage"
Shell.NavBarIsVisible="False" //hide the navigationbar
>
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal">
//define your custom navigationbar
</StackLayout>
<StackLayout Orientation="Vertical">
//content
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2139 次 |
| 最近记录: |