Respond to split-screen changes in Xamarin.Forms - xamarin.forms

In my Xamarin.Forms app, I have a MasterDetailPage with MasterBehavior set to Split when the device Idiom is Tablet. That is, I always want master page to be displayed.
The exception is during multitasking. For example, on iOS, if the user enters Split View, then I want the app to behave like it's on a phone, with no split view, but instead just a master or detail page displayed, and the proper navigation controls to move between them.
It seems like MasterDetailPage wants to help me with this. When I drag up another app to enter Split View on iOS, my app no longer shows the master page. However, the detail page that remains has no navigation control to return to the master.
What is the proper way to detect the mode change and dynamically adjust the navigation in Xamarin.Forms when your app enters and leaves Split View on iOS or split-screen mode on Android?

Related

Xamarin.Forms. Navigate from detail to master page on swipe

There is a list on the main page. When you tap on item opens page with full data about that item (Navigation.PushAsync). I need to implement on Android and iOS, so that when you swipe back on master page(Navigation.PopAsync).
As below shown:
I am using SwipeGestureRecognizer. But the animation itself (pull the page) I do not have.
How to implement this on gif above?

Xamarin.Forms Master/Detail back stack with Prism

I'm using Xamarin.Forms with Prism and a Master/Detail to create a "hamburger" menu. When the app runs, I navigate to NavigationService.NavigateAsync("MyMasterDetailPage/MyNavigationPage/MainPage");
I have items in the Master flyout menu for navigating to other pages. So I tap one and navigate to MyNavigationPage/SyncPage. At this point, if I hit the back button on Android, the app closes. Instead, I'd like to navigate back to the MainPage. I tried to hook into OnNavigatedFrom of the SyncPage to force navigation back to MainPage but the app is already closing by the time that event fires.
Implement the INavigationPageOptions interface on MyNavigationPage and set ClearNavigationStackOnNavigation = false
I implemented a solution similar to what Brian suggested but had to add a check to return true if it's the first time through in order to work correctly.

Xamarin.Forms Back Stack of NavigationPage inside Details view of MasterDetail using PRISM

I'm using Xamarin.Forms with PRISM. My app start with navigating to MyMasterDetailPage/MyNavigationPage/MainPage. From the master page, I want to navigate to page2 and have a back arrow instead of the hamburger icon. Pressing that takes you back to MainPage and the hamburger icon is back. I have tried navigating to MyNavigationPage/page2 andMyMasterDetailPage/MyNavigationPage/page2` but it seems to be clearing the back stack. There may be other pages that need the behavior that I'm currently seeing, so being able to configure the behavior would be ideal (not always one way or the other).
You need to implement the INavigationPageOptions interface on your MyNavigationPage and set the ClearNavigationStackOnNavigation property to false.

How to add context menu Xamarin.forms

I would like to create context menu in my project. On android it's called PopupMenu. On click of button, I have to show the popup with 3 rows and it's clickable event. How I can implement this in my code? Example of this menu here:
http://www.javatpoint.com/images/androidimages/popup2.png
The Xamarin.Forms way to handle this is to call DisplayActionSheet() on the Page.
It's not exactly a popup, but on the other hand it has better chances to be fully displayed and visible on screen if your view can scroll.

Launch watchkit app from long custom notification content area

I'm trying to implement a feature such that users can click on the notification content area (not app icon nor action buttons) to bring the main watchkit app open. The current official way to launch the main watchkit app is to tap the app icon or action buttons in a notification scene. But I feel like the app icon is actually quite small (and hard) to tap and sometimes users are not even aware of this feature.
What I'm trying to do now is to put my notification content into a table row in the notification controller and make this row clickable. This will give user a pretty big area to tap with. Then in the click event handler I'm trying to open the main watchkit app. But I haven't figure out a way to do that (none of the general navigation methods such as presentControllerWithName works from notification controller).
Any suggestions?

Resources