My Xamarin forms application has a login page, upon login it shows a tabbed page as the main page with 3 tab pages(navigation page). Each tab page has collection views and other controls. When we logout we set - App.Current.MainPage = LoginPage to show the login page.
Everything works fine. While running xamarin profiler we noticed that the tabbed page and it's children are still in memory. If I login 3 times, I can see 3 instances of the main tab page and each instance has 3 tab children.
Before we logout, we dispose off all the events,timers etc, but the pages are still in memory. I tried to do a PopAsync() but since it's tabbed page it threw an exception. Can anyone please tell me how to remove the tabbed page and it's children from memory?
Related
So I have a tabbedpage with 5 pages, Now when I navigate to the page where there is the tabbed page it loads all of the 5 pages that's why it's loading for so long. Is there a way to load only the open page rather than loading all of them
Per the Xamarin docs: The TabbedPage does not support UI
virtualization. Therefore, performance may be affected if the
TabbedPage contains too many child elements. So it really depends upon
how you are constructing your pages and if you are using page swiping
and off screen caching (on Android it is using a native ViewPager)
I'm using prism and had a MasterDetailPage with some pages that is accessible from that. But, in some of this pages, I can navigate to other pages that is not accessible from the MasterPageDetail Menu, but menu is still accessible with sliding action. I'll post some prints to try explain.
That's is a page that is accessible from MasterPageDetailMenu
When the user is accessing this page, he can access the MasterPageDetail Menu. But if the user select an item of the list or click in "Plus" Floating Button, the app navigate to other Page where MasterPageDetail Menu shouldn't be accessible.
But, as you can see on the next image, if the user slide the page from the left to right, the MasterPageDetail Menu is still accessible
How can I avoid this behaviour?
In the App class, my code for navigate to MasterPageDetail is:
await NavigationService.NavigateAsync("Menu/Navigation/TipoItensCardapio")
In this case, menu is my MasterPagelDetail.
The code for navigate from TipoItensCardapio page to the second page is:
NavigationService.NavigateAsync("TipoItemCardapioEdit");
If you intend for a specific page to not allow the drawer to be swiped out it sounds like you should probably be pushing it as a Modal instead of a normal Page. For example:
await Navigation.PushModalAsync(new YourPage());
For more info about Xamarin.Forms modals I'd check out the docs
I am using Prism for Xamarin Forms application development.
May be because I am new to both Prism and Xamarin Froms because of which I am facing a basic issue with the navigation.
Let me start with the details of my implementation and then the issue at hand.
I have a MasterDetail Page (named Home) which is my main page.
There are a few menu items in the Master Page. One of them is Partner.
On Click of Partner menu item, NavigationService.NavigateAsync("Navigation/Partner") method is called. Where "NavigationService" is of type "INavigationService".
This opens a page called "Partner" which is a tabbed page (TabbedPage). The first tab is a contentpage called "PartnerAll".
PartnerAll page contains a listview. On click of a list view item, a new page is opened "PartnerDetails" by calling NavigationService.NavigateAsync("Navigation/PartnerDetails", parameters, false, true);
On PartnerDetails page, I have added a toolbaritem called "Cancel".
Issue: When "PartnerDetails" page opens up, "Cancel" item shows up twice, as shown in the screenshot:
screenshot of partner details page with two cancel buttons
Where is it I am going wrong. What should I do to make it work?
Please assist.
Best regards, Ankur Jain
You’re pushing two NavigationPage’s onto the Navigation Stack. This would result in two Navigation bars. You can see in your screenshot you have both a back and a hamburger menu icon.
You should just pass in the identifier string for your destination page, instead of pushing another instance of the NavigationPage onto the stack
do it like so NavigationService.NavigateAsync(PartnerDetails);
I've been tinkering with Xamarin forms and I have run into a bit of a road block. I have an app whose rootPage is a TabbedPage. I programmatically add three child Contentpages to this page. All this works fine. However, these pages open up other pages which may or may not open other pages etc.
I have tried to use ContentPage for the child pages and pass the rootpage Navigation property into them and use that to call Navigation.PushAsync I have also tried to make the pages navigation pages and then call Navigation.PushAsync on their own property: this throws some unhandled exception
Can anyone please help!
The root of each tab in your TabbedPage should be a single NavigationPage, which wraps a ContentPage. From that ContentPage you navigate to other pages by using the Navigation property of the page.
I'm developing application that start page depends on file existing in isolated storage.
If file doesn't exist my application shows some form to setup configuration, but if it exist I wish this page will not be diesplayed.
For now I just load configutarion page but if file exist i use NavigationService to navigate to proper page on pageloaded event. The problem is that after I play with my app and hit back button it goes to configuration setup and because file exist it navigates me stright to my app again. I despite the fact that setup screen blinks on the application launching.
So my question is - how to setup startup page depends on some condition ?
The advice that I've heard is to use a UserControl on your startup page - then toggle the visibility depending on the condition you have. That way you don't end up with an unwanted page in the backstack and you get to fully control the UX.
The example I heard it with was a login page - not something you want on the backstack usually - but something you can easily check a bool to hide/show the user control.
The place I heard it was this video from Mix 11: Expert Lessons: Top Tips for Building a Successful Windows Phone Application. You can download the code to the demo (it is the first demo in that video) from the bottom of his blog entry here (which gives some more detail): Demos from my Mix 2011 session - Part 1: Navigation Tips
There is no way to launch different page on some conditions.
There are methods to manipulate Page Stack in NavigationService class, so you can remove setup page from history and app not will be navigated to it when user tap back button.
For fighting with page blinking you can put an image (the same image as splashscreen) above your page, and hide it when right content loaded