Creating the navigation/flow of a MAUI application - xamarin

My application is fairly simple, but I'm having issues with how best to setup the navigation/flow of my app using Shell and whether it's best to use Current.GoToAsync() or Current.Navigation.PushAsync() to go between the pages. (Or if there's a better way.)
My app starts off with a splash page, then to a login page, then to a tabbed page with 2 options. Each of those tabs show pages with list views where clicking on one of the items takes you to a detail page with a back button to go back to the list view page.
There's also a settings button in the header of the tabbed page that will display a flyout page of settings.
This crude drawing kinda shows what I mean.
Currently, in AppShell.xaml I have:
<Shell>
<ShellContent ContentTemplate="{DataTemplate views:SplashScreen}" />
</Shell>
After the user logs in they're taken to MainPage.xaml which is a TabbedPage setup like so:
<TabbedPage>
<views:DemoPageA Title="A" />
<views:DemoPageB Title="B" />
</TabbedPage>
Unfortunately, I'm always seeing a back button on every screen. I don't want users to go back to the splash screen or login screen, for example.
I'm just not sure if I need to somehow define my app differently in AppShell.xaml.cs or what. Any ideas are appreciated. Thanks!

You can add the following code to your page to hide the back button in the shell:
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="False" IsVisible="False"/>
</Shell.BackButtonBehavior>
Here is related article about it: Back button behavior| Microsoft

Related

Xamarin Forms shell Navigation - different page content for logged user

So, I'm making app in Xamarin Forms, and I'd like to have different content of page if user is logged.
I was already trying to achive this with pushModalAsync but result page do not have Flyout menu witch is important to me.
One solution that comes to my mind is to put two different content i want to show in frame and bind this frame`s IsVisible property to IsLogged. Is it better way to do this?

Prism Navigation keep MasterPageDetail menu after navigating to other page

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

Prism Xamarin Forms ToolbarItem appearing twice

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);

Xamarin Forms Bottom Navigation Bar

In my Xamarin forms application I need to add a bottom navigation bar in every pages. Bottom navigation bar should have 7 buttons and tapping on each buttons should navigate to corresponding pages. Is there any way to implement this in Xamarin forms?
Yes I have implemented this using this plugin Bottom Bar Plugin it is a very useful plugin which renders tab bars at the bottom of the screen for android and IOS. Even though all the documentation you will need is available via the link I mention, the stackoverflow bots will swarm me unless I add that you can navigate to the site in question by searching google for
BottomNavigationBarXF
other than cutting and pasting their documentation for the benefit of this site (so that anyone referrring to this answer in the event of a thermo nuclear war, after which stackoverflow is the only surviving site, can still contextualise this answer), I would urge you to consult their documentation which is well put together.
You can use Tab page itself. For iOS, by default tab pages button are at bottom. For Android, there is a way to move the tabs to bottom. You need to update Xamarin or Visual Studio. After updating, add the below page directives to the Tab page Xaml code.
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
For example:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
android:TabbedPage.BarItemColor="#a39d9f"
android:TabbedPage.BarSelectedItemColor="#007aff"
android:TabbedPage.IsSwipePagingEnabled="false"
x:Class="TabbedPageWithNavigationPage.MainPage">
<local:TodayPage />
<NavigationPage Title="Schedule" Icon="schedule.png">
<x:Arguments>
<local:SchedulePage />
</x:Arguments>
</NavigationPage>

Create Page custom animations in Windows Phone 8.1 (Windows Runtime)

I would like to develop some animations for my pages or my page content. The approach of which one I should follow is unclear to me at the moment and I'll try to explain why.
What I'd like to achieve is to create a page (or page content) animation with a slide-in from right when navigating to the page and slide-out to left when leaving the page.
The slide-in part can be achieved with ContentThemeTransition from TransitionCollection. But what about the slide-out part?
I can't seem to know or find any good timing regarding when to fire a slide-out animation just before the page is about to be left.
I'dlike not to apply any animation to the page in such way that WP does by default (with some jump-out, jump-in effect). I'd like to be like BasicPage from templates with no animation but with custom animated content upon page enter and page leave.
How could this be achieved?
Thanks in advance.
I assume you are navigating from the page via tapping a button or something similar. Why don't you create a storyboard animation, start that from the Click event handler of the button, and call Frame.Navigate() when the animation has finished playing?

Resources