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>
Related
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
I am adding iOS support for my already existing Xamarin Forms android app.
The toolbar items, navigational back arrow and the hamburger menu do not show on iOS:
While they work perfectly on Android:
The Application.MainPage is set to a Shell:
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="app.MainPage"
FlyoutBackgroundColor="{StaticResource cBackgroundColorDark}"
Shell.TabBarTitleColor="{StaticResource cBackgroundColor}"
Shell.BackgroundColor="{StaticResource cBackgroundColor}">
<Shell.Resources>
<ResourceDictionary>
<vm:FlyoutVM x:Key="vm" x:Name="vm"/>
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader>
</Shell.FlyoutHeader>
<ShellContent Title="page1"
IsTabStop="True"
ContentTemplate="{DataTemplate views:Page1Page}"/>
...
<Shell.FlyoutContent>
</Shell.FlyoutContent>
<Shell.FlyoutFooter>
</Shell.FlyoutFooter>
</Shell>
The page with the toolbar items is simply:
<ContentPage>
<ContentPage.ToolbarItems>
<ToolbarItem Text="Example"
IconImageSource="Example.png"
Clicked="ExampleToolbarItem_Clicked"
/>
</ContentPage.ToolbarItems>
</ContentPage>
All navigation (hamburger menu, back button ect) and toolbar items can be tapped on iOS and work as intended - they just are not visible.
I do not understand why this does not work on iOS, any suggestions why this might be the case?
(I cannot find any styling that might be making it act differently. I have also tried displaying a toolbar with just text (no icons) and the problem persists)
I can provide more code if needed.
EDIT
I ended up creating a new Xamarin shell template project and moving everything over. That fixed the issue...
Most likely the image size for ios is incorrect. I use this https://appicon.co/#image-sets to create image set for ios.
I'm developing an app using Xamarin with .netstandard 2.1 and can't find a way to change the action bar of the android app.
The blue bar isn't the color I want, and following all the docs and tutorials over internet, I found even a way to change the status bar (where the clock and battery and notifications are), but can't change this blue to Orange.
Can someone tell me what should I'm doing wrong, please?
Thanks
Set the attached property BackgroundColor="Red" either globally at <Shell> level:
<Shell
...
BackgroundColor="Red">
Or at ContentPage level using:
<ContentPage
...
Shell.BackgroundColor="Red">
note that this will affect navigation bar (the one you described) and also upper tabs (TabBar).
Inside your shell app xaml file, at the top use Shell.BackgroundColor="Red".
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1.Views"
Title="App1"
x:Class="App1.AppShell"
Shell.BackgroundColor="Red"
>
In Xamarin Forms, I am using
<ContentPage
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true" >
to make the Application UI compatible with iPhone X, but its working only in iOS 11. Anyone have a suggestion on how to make this work on all iOS devices?
The concept of the safe area is exclusive to iPhone X, hence to iOS 11+. Anyway, per default an app uses the whole phones screen (as opposed to Android), hence, if the status bar is shown (you can hide it if you need, but that's another story), your app will overlap it.
Xamarin.Forms NavigationPage will automatically adapt to the available area (others maybe too), but if you are using a bare ContentPage for example, you'll have to take care of by yourself.
To handle things differently on different platforms, there is the OnPlatform tag in XAML (see here). With that you can add a platform-dependent padding to your ContentPage
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,20,0,0" />
</OnPlatform>
</ContentPage.Padding>
which will prevent your page overlapping the status bar.
I'm using Xamarin Forms with Prism and I need to create a layout with a sidebar menu and a fixed bar at the bottom of the screen with quick actions like instagram app for iOS and Android.
I was thinking in use MasterDetail but how can I add that fixed bar at bottom of the Detail controller and keep it when detail page changes?
And the second thing is that I have a specific page that has form sections separated by tabs, so how can I render tabs at the top of the page for iOS (like Android)?
Something like this: