PRISM Library: Transition animations not working when using absolute navigation in the NavigateAsync call - prism

Basically I would like some help with navigation in the prism library. I have been using NavigateAsync method to navigate through pages in my xamarin forms app. No issues with it.
I have been navigating from PageA -> PageB using NavigateAsync("PageB") and I am getting an animation while navigating to PageB. Due to some requirements, I need to reset the navigation page stack when navigating to PageB, so I have decided to use absolute path in the navigation with NavigateAsync("/PageB").
The stack gets clear as expected, but unfortunately, the animation while navigating to PageB is gone, and the page just show up without any animation.
Does anyone knows how to activate the animation when using absolute path in the navigation in PRISM?

Related

Difference between Prism Dialogs vs Popup

I am implementing Prism in a new Xamarin Forms App. I have been using Rg.Plugins.Popup in the app before converting to Prism.
What are the limitation on the Prism Dialogs vs Prism.Plugin.Popups?
What are some examples when you would use one over the other?
Thank you!
Rg.Plugins.Popup is a popular plugin for Xamarin.Forms which accesses the native functionality to provide a "Modal Popup" which traditionally has not been achievable with Xamarin.Forms.
Dialogs in Prism 7.2
If you're using Prism 7.2 you'll find that the DialogService locates the currently displayed page and then "reparent's the content". Or in other words it takes the content of the active Content Page and places it as the root child of an AbsoluteLayout, placing a mask layer and finally your dialog on top. As a result of this approach you'll notice that any navigation bars for instance on the NavigationPage or TabbedPage, or a MasterDetailPage's menu will remain accessible to the user.
While in some regard both the PopupPage and Dialog may look very similar as you can probably tell there is some significant divergence there.
Dialogs in Prism 8
If you're using Prism 8.0 you'll see that we have updated to the latest Xamarin.Forms and as a result we are able to take advantage of a new feature in Xamarin.Forms which allows you to present a Modal Page with a Transparent background. This in effect allows you to replicate the effect of a PopupPage with either some benefits or drawbacks depending on how you look at it.
With Rg.Plugins.Popups you have the ability to push a PopupPage on top of whatever page is currently displayed from anywhere in the app
With Xamarin.Forms page's that have been pushed Modally they are part of your active Navigation Stack
Using the a traditional page with a transparent background and Modal Navigation you in effect have replicated the appearance of what you get with a PopupPage
Limitations
Prism.Plugin.Popups has the benefit of being integrated into the Navigation Service. As such you can inject the Navigation Service into the ViewModel of a PopupPage, and the PopupPage will be dismissed when you navigate away from it to another non PopupPage.
Dialogs are not part of the Navigation Stack tracked by Prism's Navigation Service. Navigation in Xamarin.Forms is dependent on navigating FROM a specific page. Since Prism's NavigationService doesn't know about the Dialog you will need to dismiss the dialog before navigating.
Other Key Differences
Besides what I've mentioned so far the only real difference is that Rg.Plugins.Popup gives you some added animations which honestly I've seen very few people using.

Modal form is empty with PushModalAsync with Xamarin.Forms.Maps

I have a form that includes a Xamarin.Forms.Maps.Map control. When I push new views onto the stack with await Navigation.PushAsync(page), views that I want to be modal (using await Navigation.PushModalAsync(page)) that I push onto the stack are empty. The animation works fine, but what's animated is just empty (the background is white but with no controls or other UI elements rendered. If I remove the map control from the "root" view, the modal pages are displayed correctly. If I use .PushAsync instead of .PushModalAsync the views are displayed correctly.
I am targeting Android 6 using the Google emulators
I have no idea what's going on.
it looks like we have a bug on the Xamarin Forms ModalNavigation. It was already reported here: https://bugzilla.xamarin.com/show_bug.cgi?id=43692
For now, I'm using this workaround (from Scott Simms): before pushing a any page (in the OnDisappearing()) from a page that contains a MapView, remove the MapView from the Content of current page, and load it again in the OnAppearing();
It works well for next page BUT... if you push a new wrapped ModalPage on this second page, when you pop it, probably it will crash your app too.
It has been bothering me, and I am thinking about implement my own toolbar to make it looks like a Navigation Page and avoid the annoying crashing.

Is there TOP VIEW(or window) on xamarin forms?

I'm making app with using Xamarin.forms.
I wanted to know if there is top window or view for Xamarin.forms.
I want to put something like a alert or indicator so that it remain on top depth all the time until it's gone. (even if new page is pushed.)
I can't find any view or window on XF.
Should I use each native window?
Thanks.
You can try to use Application.Current.MainPage.DisplayAlert method to display alert from the MainPage (which ordinary always exists in app).

Custom Navigation with Xamarin.Forms

I’m working on an application for Android and iOS, which requires a certain flexibility for one or two views. That’s why we created & implemented a service that translated a basic list of objects into a user interface for both iOS & Android. But now that Xamarin.Forms is released, we decided to replace our service by the one Xamarin provides. I did succeed in creating the views with Xamarin.Forms, resulting in better looking & smoother running pages. But my problem lies in the navigation of it. Here is a little drawing on what I would like to achieve:
I would like my app to start an activity that starts with a custom fragment. After clicking a button on this fragment, I would like the page I created with the Xamarin.Forms api to be added to my current navigation stack! Once the user is finished with the Xamarin.Forms page, it navigates to a second custom fragment, all that without breaking the navigation cycle. Does anybody have an idea on how I can achieve this?
For the iOS developpers: replace Activity with NavigationController & Fragment with ViewController
Take a look at CarouselPage for Xamarin.Forms' own approach. It doesn't look like that's what you need but you can also look at its source code and maybe make a custom renderer yourself.
You may also want to take a look at MVVM
As for the easier/hackier way you'd want to make a button on each page and when the button is tapped execute Navigation.PushModalAsync(nextPage) - there won't be a "< Back" button any more, you may need to implement that yourself if you need it.
If by your meaning of 'current navigation stack' is for using the native Navigation of each platform, then remember that you don't have to use Xamarin.Forms' Navigation Model and functions such like PushAsync.
If you prefer to do Navigation with code specific to each platform then you can do this the same as normal. Just create your stub pages in each platform specific project and set the Xamarin.Forms content for each page from the shared project.
From each platform specific stub page (Activity / UIView / PhoneApplicationPage) you could then execute an Action<> call setting on the shared Xamarin.Forms page to help with the navigation, or alternatively, hook into a custom-event that is raised from the Xamarin.Forms** page back to the platform specific stub page to allow you to do navigation from there.
Like Sten mentioned there won't be any 'Back' button so you will most likely have to do that yourself.

Non Linear Navigation Service

I'm creating an app that has start button which brings you to start page from anywhere in app.
However back navigation stack hurts when I just navigate to start page.
Looking for solution I found NonLinearNavigationService. The trouble is that download links are target to app hub, which (now, as we have new better app hub) redirects me to main page and nowhere further. Also I failed to find it on app hub using build in search engine.
Anyone knows where from can I get it?
Or maybe another solution for navigation loops?
If you use RemoveBackEntry(), the entries are programmatically cleared from the backstack so you don't have to deal with the side effects of actually navigating back through the pages to pop them off the stack.
The NonLinear Navigation Service effectively does what you have tried. It calls GoBack() to traverse back up the stack. What it additionally does to prevent the flicker is to make the root frame transparent. See this question:
Skip a page when the back button is pressed, WP7
I don't want to call your question a duplicate because I think before Mango came out, that was probably the solution that needed to be used. Now that RemoveBackEntry() has been added to NavigationService, I think using that would probably be the better approach.
No linear navigation in WP7 is generally not recommended, because of the hardware back button and the UX on the rest of the phone, so you should probably structure your app to avoid this. However it should pass the certification process.
Here's another similar question In-App Home Button to Navigate to MainPage allowed? and an article about circular navigation which mentions the NonLinearNavigationService you are talking about http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/12/13/solving-circular-navigation-in-windows-phone-silverlight-applications.aspx.
If the only non-linear part of the navigation is the home button, you could use NavigationService.RemoveBackEntry() in a loop untill it raises an InvalidOperationException in the home button event. When the InvalidOperationException is raised the BackStack is empty and the next click on the back button exits the application.

Resources