My team have been struggling with this for few days.
We are porting a swift app over to Xamarin.Forms using MVVMCross
(This is our first play with Xamarin.Forms)
Our app consists of 4 main viewcontrollers and we have numerous modals views that appear as a 'FormSheet' (so they appear NOT full screen and can be sized). In swift we embed each modal view within a navigation controller.
We are struggling how to do this behaviour in Xamarin.Forms
We have created our main view controllers and can switch using
await _navigationService.Navigate<...ViewModel>();
What we can't do is either load the modal view (so they appear as modal view) or load the view in a new navigation window (again as a modal view)
In order to open a page as a modal you must add the attribute to forms page on code behind
[MvxModalPresentation(WrapInNavigationPage = false)]
public partial class YourModalView : MvxContentPage<YourModalViewModel>
I would highly recommend you to check the presentation attributes from MvvmCross for Xamarin.Forms
Related
I have a Xamarin.Forms application using Prism (Xamarin.Forms v4.5.0; Prism v7.2.0).
The main application is 4 tabbed pages. Using the Prism NavigationService I can switch tabs easily using something like this - NavigationService.SelectTabAsync("Page2");
But if the user presses the back button, it just exits the application.
Is there a way to add the tab changes into the navigation stack so pressing back would just go to the previously selected tab?
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?
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.
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.
I'm pretty new to iOS development and I'm having some trouble with navigation controller and a collection view as a Subview.
Ive started my project with a single view application and embedded in a Navigation controller (The Navigation controller root is my ViewController).
Inside my view controller i've added a Collection view with a custom cell (it doesn't take the whole screen).
when I run my application everything works fine.
when I tried to set the method
navigationController?.hidesBarsOnSwipe = true
nothing happens inside my Collection view even though I'm scrolling, but if I swipe within the View controller and not the Collection view the method works and the Navigation bar gets hidden just fine.
I want the method to work when I swipe inside the Collection view.
Thank...
If your collection view top is set to the top layout guide top then the view behind is has never scrolled, i.e. your view isn't scrolling so the navigation bar is not hiding.
Try setting your collection view top to the "Top Layout Guide.Top". Try changing this to "Superview.Top".