Views navigation with Xamarin.forms MasterDetail page and caliburn.micro - xamarin.forms

I want to implement a menu using a masterdetail page with caliburn.micro, but the only documentation i managed to find is this.
I know I have to use a NavigationPage inside MasterDetailPage.Detail and load my views into that, but I can't find any example of how MasterDetails composition works and how can I navigate from view to view (for example, for prism there's this).
Any help would be appreciated.

Related

How do I change the content shown in the master section of a master detail page using Prism

I'm migrating our app from MvvmCross as we need to add Intune support and using MVX is preventing this.
The app is essentially an email reader, so currently we are using a MasterDetail page and loading a folder list into master which on phones becomes the flyout and on tablets this appears in the left of the split view.
When you select a folder from this page we then show a message list - this loads into the detail on phone, but for tablets we use MVX functionality to load this into master, this is also wrapped inside a nav page so you can go back to the folder list. Essentially we have a nav stack inside the master section on tablets and also one in the detail section.
I've checked and played around with the Prism samples, but they don't appear to cover this scenario. The documentation recommends only having fixed content in the master section and this is bound to the master detail view model. This is different to what we have currently, essentially we can control where any page ends up depending on idiom.
I would just like confirmation that it is possible for me to be able to load a page into detail or master depending on the device idiom and any examples would be greatly appreciated!
The Master property of the MasterDetailPage is a basic Page object so it does not have a navigation stack available but the property itself does have a getter and a setter so you should be able to set the page manually. We use a master page and as a quick test I was able to set it using:
((MasterDetailPage)Application.Current.MainPage).Master = new SwapMaster();
What might be possible that I didn't try is actually set the Master as a NavigationPage. Then you might be able to push onto the Master's navigation stack. Again, I did not try this ATM.
Update:
So I did play around quickly with setting the Master to a navigation page and then pushing and popping pages on and off the stack. It did work but the behavior was a little squirrelly but it does show it might be possible.
Push on the stack:
((NavigationPage)Master).Navigation.PushAsync(new SwapMasterPage());
Pop the stack:
((NavigationPage)((MasterDetailPage)Application.Current.MainPage).Master).Navigation.PopAsync();
I've answered this myself by taking a look in the source and there is no support in the Prism navigation service to load a page into master. Everything is overridable, but I feel it would result in lots of changes and issues if I try and introduce this concept.
We'll have to discuss internally if changing the UI flow on tablets is acceptable, if not then Prism is a no go and we'll look at alternatives or write our own navigation service to support it.

Is there a way to have a tabbed page in a content page

There's a page in the app i'm developing currently. After some UI (image, text), i have some tabs which navigate to different pages. However, you can't have a tabbed page in a content page using the regular xamarin.forms
Solution1:
Like Jason said, custom control could simulate tabbed behavior.
You could download from the GitHub for reference.
https://github.com/CrossGeeks/SegmentedControlSample
For more details, you could refer to the article below.
http://www.xamboy.com/2018/01/12/segmented-bar-control-in-xamarin-forms/
Solution2:
You could do that with CarouselView as well.
Download from the GitHub.
https://github.com/chrisriesgo/xamarin-forms-carouselview
For more details, you could refer to the link.
https://chrisriesgo.com/xamarin-forms-carousel-view-recipe/
The original image is not obvious enough, you could change pin.png to icon.png in PagerIndicatorTabs.cs.

UI issue with Prism MasterDetail implementation

I am using github.com/PrismLibrary/Prism/tree/master/Sandbox/Xamarin/HelloWorld to implement MasterDetail using Prism.
I have successfully ran the example and all is fine but the menu is covering phone top notification area. How can I solve this?
Please see the issue here
In Xamarin example https://developer.xamarin.com/samples/xamarin-forms/Navigation/MasterDetailPage/
this issue is not happending.
Do I have to do some addition trick with Prism that is not done in HelloWorld example?
Thanks
Tadas
That is an old sample that does not use Material Design. All the newer Xamarin.Forms templates utilize material design which result in the master showing over the topmost bar. You could also try playing with the MasterBehavior property to control how the master behaves.

RxUI and Xamarin Forms: Is it possible to create Modal Pages?

I'm currently evaluating RxUI for future projects and so far I like what I see.
I was able to create a first test project and navigate between pages using
HostScreen.Router.Navigate.Execute(new NewReleasesViewModel(HostScreen)).Subscribe();
Which creates a normal ContentPage with Backbutton.
I wonder how I can navigate to the ModalPage stack and display modal pages.

MasterDetail and NavigationPage deeplinking in Prism Forms

I am testing the deeplinking feature of the Prism Forms framework. I currently have a situation where I have a MasterDetailPage with a menu as Master. When I click the menu items, the Details should change to specific pages with a clean NavigationPage as container.
When I check the Sandbox example for Prism Forms, it shows an example for MasterDetail navigation, but not including navigation pages.
So I have this (absolute) deeplink structure at startup: /MasterDetailPage/NavigationPage/MyFirstPage
Then I want the second menu item to link to a fresh NavigationPage:
/MasterDetailPage/NavigationPage/MySecondPage
My current workaround is to do absolute deeplinking, but I was wondering if there is a better way? The Prism PageNavigationService checks to see if the segment type is the same as the current detail type. But since these are both NavigationPages, it tries to add the new page in the already existing NavigationPage. At that moment it also kills the menu-icon (at least on iOS).
Actually, the Sandbox app does use NavigationPages in the MasterDetail: https://github.com/PrismLibrary/Prism/blob/master/Sandbox/Xamarin/HelloWorld/HelloWorld/HelloWorld/Views/MyMasterDetail.xaml
Prism reuses the detail page for performance reasons, but it doesn't work like you think it does. While it does add the new page to the NavigationPage's NavigationStack, it also removes the previous page from the stack. This keeps the NavigationStack in the proper state.
The icon behavior you are seeing is because of a confirmed bug in Xamarin.Forms. You can follow the issue here: https://bugzilla.xamarin.com/show_bug.cgi?id=41038
As soon as Xamarin fixes this bug, I will publish the fix to Nuget. In the mean time, the only way to get around this is to fork the Prism code base and remove the Page type check.

Resources