I am trying to create a Master Detail page with inner Navigation. So if you go to DetailPage 1, for example, you will see a list of size n. Ideally, when you press a list item, you get taken to a new page. However, on this new page, I have no way to go back to the Master Detail Page. Pressing the Back button on my Android phone minimizes the app, and the Master Detail view is gone.
I searched around a while, but couldn't find any posts resolving this specific issue. I've tried creating a new DetailPage, and having the user navigated there. That worked, but it looks ugly and user unfriendly.
My code follows this Microsoft tutorial: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/master-detail-page
If needed, I can post some examples but I don't think that would be necessary.
Expected result, navigation shown from top to bottom:
Master-Detail Page
Detail (NavigationPage)
NavigationPage.PushAsync(newPage)
just wrap your detailpage in navigation page and add a toolbaritem and your problem is solved!
like this :
var detailpage = new NavigationPage(new YourDetailPageName());
Related
I am having this little drawer menu in my master detail page. I have a list with clickable options there and some navigate you to another screen:
Application.Current.MainPage = new NavigationPage(new Screen_Profile("", true));
But this results in the loss of the navigation arrow to go back. If you click back on android, the app just closes afterwards.
How can I navigate away from the master detail page and still have the arrow to just come back to the main page?
Thank you!
you only want to update the Detail page, your the entire MainPage
var mdPage = (MasterDetailPage)Application.Current.MainPage;
mdPage.Detail = new NavigationPage(new Screen_Profile("", true));
this will leave the Master portion of the page with it's menu active as you Navigate
What is the difference between these two Navigation paradigms in Xamarin.Forms?
await Navigation.PushModalAsync(new Dashboard());
await Navigation.PushModalAsync(new NavigationPage(new Dashboard()));
What is a Modal Page
Navigation.PushModalAsync will cause the new Xamarin.Forms.Page to appear Modally, meaning its animation will start from the bottom of the screen, covering the previous current page and it will not contain a back-button.
On iOS, a user will not be able to swipe-left to return to the previous page.
Android users are able to use the hardware back button to dismiss a modal page.
Modal pages are useful when you want the user to make a conscious decision to dismiss the page.
Example
When an iOS user is filling out a form and they swipe left to go back, does it save the form or discard the form? It is unclear to the user. To make the UX more intuitive, you should display the form modally
UI Differences
Using await Navigation.PushModalAsync(new Dashboard()); will display the Dashboard Page Modally, but the new Page will not have a NavigationBar.
Using await Navigation.PushModalAsync(new NavigationPage(new Dashboard())); will also display the Dashboard Page Modally, but the new Page will have a NavigationBar.
Sample App Source Code: https://github.com/brminnick/XamList
Edit
#AlessandroCaliaro and I had a good discussion in the comments of his answer, below:
It's important to note that Xamarin.Forms.INavigation uses two different stacks, ModalStack and NavigationStack. Navigation.PushModalAsync adds a Page to the ModalStack and Navigation.PushAsync adds a Page to the NavigationStack.
And to pop a Page from the ModalStack, you need to use Navigation.PopModalAsync(), whereas you would use Navigation.PopAsync() to remove a Page from the NavigationStack.
The first, push a page in a "modal" way (without navigation bar on the top)
the second... is an error because you try to add a navigationpage to a navigationstack, but I think it is not possible....
Here's the scenario:
I'm working with Xamarin forms and using FreshMVVM.
My main screen is a FreshTabbedFONavigationContainer, one of the tabs navigate deeper into other pages while the others don't. If I'm in one of those deeper pages and do:
CoreMethods.PushNewNavigationServiceModal(...)
the next navigation page is added to the stack and the back button appears and works fine.
But if I call the same method from a root page in my main tabs page, the back button doesn't appear. I'm calling the same method, the same way, with the same argument types. I've even tried the same arguments.
Why would it work from a deeper FreshBasePageModel and not from the first FreshBasePageModel in a FreshTabbedFONavigationContainer? I've tried FreshTabbedNavigationContainer too and it made no difference.
Also, is there a way to force the back button to show and manage its behavior?
I'd like to ask you, what do you think, which control is better for navigation. What I mean?
Now I have Pivot control with 2 PivotItems. One of them is named Contacts. This PivotItem contains Frame. And the frame makes new navigation on page with contacts (listview). Why Frame? When I click on some contact I need to show details of current contact. But I need to display it inside PivotItem, therefore I use inner frame. So I can still see main view and other pivot items. I think, that pivot is not right control for it. Or I should show contact details for whole screen, not only in pivotitem.
FrameA and FrameB. FrameA has navigated from Main to Page1. Page1 has a Pivot that hosts FrameB in PivotItem1 and FrameB has navigated from View1 to View 2 and from View2 to View 3
I suggest you start reading up on navigation basics for Windows 10 and look at some other apps how they do it.
You could use a navigation pane (which is mostly done using a SplitView), in which you show your contacts grid in the main panel and navigate to a single contact when clicking on it. The other item in your navigation pane would be the title for your 2nd pivot tab.
If you want to keep your contact list visibile at all time and show the details of a single contact next to it, the alternative is using master-detail. Either on a full screen, or by placing the master detail on the main panel of your SpltView.
You can find a master-detail control in the UWP Community Toolkit.
I have a Prism/SL3 application with a tab control and each page of the tab control is a "Region" that has its own view and viewModel. when I want to validate the main page, I call dataForm.ValidateItem(), then I go to all the child views and do the same. the problem is, only the pages which user has clicked on them (on the tab page), get instantiated and the pages that are never shown, don't have their view instantiated, thus I can't validate them.
any help?
I created a psuedo work around for this. It's very hacky, but it does work. My example involved walking the visual tree (up and down) to find respective controls that are invalid and then "expanding" the selected item. I have used an accordian in my example, but have also tested this with tab:
http://thoughtjelly.wordpress.com/2009/09/24/walking-the-xaml-visualtree-to-find-a-parent-of-type-t/
HTH,
Mark
EDIT: Link updated.