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

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.

Related

Respond to split-screen changes in 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?

HelloWorld sample code not working on Android: Back button not visible

I got the sample app from
https://github.com/PrismLibrary/Prism/tree/master/Sandbox/Xamarin/HelloWorld
I tested it on Android 6:
Run the app from sample code (no modifications), it shows MainPage
Tap on ViewA from the menu, it navigates to ViewA, but there is no back button in the app bar.
Hitting device back button works, it navigates back to MainPage.
The behavior I am expecting is to see the back button in the bar too.
UPDATE
I'm debugging Prism, and I can see clearly that Prism's PageNavigationService navigates to ViewA by just calling currentPage.Navigation.PushAsync(page, animated).
I can see that the Xamarin Forms's NavigationImpl has the NavigationStack with two pages, MainPage and ViewA. So the MainPage is still there in the navigation stack, but for some reason the back button is not visible.
ANSWER!
#lowleetak discovered that there is a call somewhere in the sample which hides the back button!
The app start in MasterDetail page. Where the MasterPage is the Menu and DetailPage is the MyNavigationPage/MainPage initially.
When you click ViewA from menu, it is changing the DetailPage from MainPage to MyNavigationPage/ViewA. It is the root/initial page in the navigation stack of the DetailPage. So, there is no Back button showing.

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.

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.

Disable UIPageViewController when ModalViewController opened

I am totaly new to this site, but I already like it :-)
I found it by searching for a question about the UIPageViewController.
I have a normal UIPageViewController App, in which I open a ModalViewController for setting up some settings...
Now the Problem: :-)
If I click on the done Button on the right side of the ModalView, to dismiss it, the PageViewController turnes the page, because he thinks that he is meant by that click ;-)
Can I disable the PageViewController GestureRecognizer as long as I have a ModalView opened?
Is there a method to disable and later his recognizer?
thank you for your help in advance...
cu Matze
It seems odd that your UIPageViewController would steal touches from a modal view presented over it. Unless, perhaps, you are embedding the modal view within the content of the UIPageViewController?
To answer your question -- you can easily disable the page view controller's gesture recognizers by enumerating its gestureRecognizers property (an NSArray):
for (UIGestureRecognizer *gr in [self.pageViewController gestureRecognizers]) {
[gr setEnabled:NO];
}
Re-enable them later with setEnabled:YES.
UPDATE:
In iOS 6 UIPageViewControllerTransitionStyleScroll has been added. UIPageViewControllers that use this transition style return no gesture recognisers in the array returned by gestureRecognizers. Presumably page view controllers with this transition style use an underlying, private UIScrollView instance (it behaves just like a UIScrollView with paging enabled), although I haven't checked this.

Resources