简体   繁体   English

如何在不使用导航的情况下在 Xamarin 应用程序中打开页面?

[英]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 已经有一段时间了,但如果我没记错的话,您有两个选择:

  1. If you want to completly reset the nav stack, you can do CoreMethods.PushPageModelWithNewNavigation<FirstChoicePageModel>();如果要完全重置导航堆栈,可以执行CoreMethods.PushPageModelWithNewNavigation<FirstChoicePageModel>();
  2. If you want to keep the nav stack, you can set 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.

相关问题 如何使用 Xamarin 为 Android 应用程序打开新窗口/页面? - How can I open a new window/page using Xamarin for an Android App? 如何在不关闭和打开我的应用程序的情况下更新 xamarin 中的数据? - How can i update my data in xamarin without closing and opening my app? 如何在xamarin中将xib设置为应用程序的第一页? - How do I set an xib as the first page in my app in xamarin? Xamarin UI.Test - 如何在登录后关闭我的应用程序并重新打开以检查登录会话是否继续? - Xamarin UI.Test - How can I Close my App after login and re - open to check Login Session is continued or not? 如何使用 xamarin android 打开前置摄像头 - How can I open front camera using xamarin android 如何在我的应用中打开锁定屏幕设置页面? - How can I open up lock screen settings page in my app? 当用户单击外部来源的链接时,如何在应用程序中打开特定页面? - How can I open a specific page in my app when the user clicks a link from an outside source? 如何从全景应用中打开一个简单的页面? - How can i open up a simple page from my panorama app? 如何使用应用程序代表页面将链接,图片等发布到我的Facebook页面? - How can I post links, pictures etc to my facebook page on behalf of my page using an app? 如何在不使用Page.Theme属性的情况下设置页面样式和主题? - How can I set my Page styles and themes without using Page.Theme property?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM