[英]How can I open page in my Xamarin app without using navigation?
I have a Xamarin Forms application, which has 2 buttons on the toolbar.我有一个 Xamarin Forms 应用程序,它在工具栏上有 2 个按钮。 Currently I'm using FreshMVVM (and it's navigation).
目前我正在使用 FreshMVVM(以及它的导航)。 I want to load pages without putting them into the navigation.
我想加载页面而不将它们放入导航中。 I do not want to have the 'back' button on the toolbar, also I do not want the user return the last page.
我不想在工具栏上有“后退”按钮,也不希望用户返回最后一页。
Here's how I push a page currently:这是我目前推送页面的方式:
CoreMethods.PushPageModel<FirstChoicePageModel>();
I tried to push as a modal, but that way the toolbar buttons does not work until I press back.我试图以模态方式推送,但这样工具栏按钮在我按下之前不起作用。 Should I make new navigation containers and switch to them if I push the buttons?
如果我按下按钮,我应该制作新的导航容器并切换到它们吗?
It's been a little while since I've used FreshMVVM, but if I recall correctly, you have 2 options:自从我使用 FreshMVVM 已经有一段时间了,但如果我没记错的话,您有两个选择:
CoreMethods.PushPageModelWithNewNavigation<FirstChoicePageModel>();
CoreMethods.PushPageModelWithNewNavigation<FirstChoicePageModel>();
NavigationPage.SetHasBackButton(this, false);
NavigationPage.SetHasBackButton(this, false);
in the code behind of the view. For both of these options, it may necessary to intercept the back button on Android.对于这两个选项,可能需要拦截 Android 上的后退按钮。 In the code behind there is an overrideable method:
在后面的代码中有一个可覆盖的方法:
protected override bool OnBackButtonPressed()
{
return true; // prevent Xamarin.Forms from processing back button
}
If you want to show a page, but you doesn't want to navigate (change the current page), you can always use Popups.如果您想显示一个页面,但又不想导航(更改当前页面),则始终可以使用 Popups。
See this link https://github.com/rotorgames/Rg.Plugins.Popup请参阅此链接https://github.com/rotorgames/Rg.Plugins.Popup
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.