Xamarin.forms: Can't use On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom)

Created on 20 Jul 2018  ·  12Comments  ·  Source: xamarin/Xamarin.Forms

Description

I have xamarin.forms project. I want android tabs at bottom for that I might have few solutions but I thought to use below one

public class MyTabbedPage : Xamarin.Forms.TabbedPage
{
    public MyTabbedPage()
     {
         On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom); //giving errors
    }
}

But the code above giving 2 errors

Error CS1929 'IPlatformElementConfiguration' does not contain a definition for 'SetToolbarPlacement' and the best extension method overload 'TabbedPage.SetToolbarPlacement(IPlatformElementConfiguration, ToolbarPlacement)' requires a receiver of type 'IPlatformElementConfiguration'

Error CS0118 'Android' is a namespace but is used like a type

Please help me to solve those errors or where I am making mistakes.
Note: If above code working for someone than it doesn't seem to call SetTabIcon of TabbedPageRenderer class. Here I am talking about android custom renderer.
For more information see the answer given by me in this question
this

Steps to Reproduce

  1. Create Tabs using TabbedPage in xamarin.forms
  2. Try code above to set tabs on bottom side in adroid
  3. Execute project

Expected Behavior

Tabs should show bottom of page

Actual Behavior

Not executing project giving compile errors

Basic Information

Xamarin.Form Version 3.2.0.637442-pre1-From nuget

Microsoft Visual Studio Enterprise 2017
Version 15.7.5
VisualStudio.15.Release/15.7.5+27703.2042
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00369-60000-00001-AA519
Microsoft Architecture Diagrams and Analysis Tools

Application Insights Tools for Visual Studio Package 8.12.10405.1
Application Insights Tools for Visual Studio

C# Tools 2.8.3-beta6-63029-08. Commit Hash: e9a3a6c0ba5b1fde8b1fff964bdfb3fb768ee2eb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

JavaScript UWP Project System 2.0
JavaScript UWP Project System

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

Visual Studio Tools for Universal Windows Apps 15.0.27703.2042
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin 4.10.10.2 (35a01d8dc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 4.12.1 (f3257e429)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.3.3.2 (HEAD/dffc59120)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.12.0.4 (64fece5)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Screenshots

xamarintabbedissue

Reproduction Link

needs-info ❓

Most helpful comment

Most likely if you are using a shared project you may run into this issues as Android is a namespace itself in projects.

Just do:

On<Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);

and just use:

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

All 12 comments

@arvindrajachourasiya are you missing a using?

https://github.com/xamarin/Xamarin.Forms/issues/1675#issuecomment-405156829

I don't think so. See MyTabbed file code. I have namespaces imported

using System;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Xamarin.Forms.PlatformConfiguration;

namespace edTheSIS.Shared
{
    public class MyTabbedPage : Xamarin.Forms.TabbedPage
    {
        public MyTabbedPage()
        {
            On<Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);
            this.CurrentPageChanged += CurrentPageHasChanged;
        }
        protected void CurrentPageHasChanged(object sender, EventArgs e)
        {
            this.Title = CurrentPage.Title;
        }
    }
}

Hi,
I have provided information you asked.

Checkout David's project over here
https://github.com/davidortinau/TheLittleThingsPlayground

And compare it to your project to see what you might be missing

Most likely if you are using a shared project you may run into this issues as Android is a namespace itself in projects.

Just do:

On<Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);

and just use:

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

@jamesmontemagno Thank you. It got fixed now.

I think we can close this. Perhaps @conceptdev we can check docs.

How to Achieve the same in FreshMvvM Placing in Bottom ? @rid00z

Hi @arvindrajachourasiya
I create project XF with .Net Standard Project, and create Bottom Toolbar with above code same you, but i still get error, can you give me a your sample project with no error. Thank in advance.

@babman92- What error are you getting?

@arvindrajachourasiya thank you, i get error
Severity Code Description Project File Line Suppression State
Error 'IPlatformElementConfiguration' does not contain a definition for 'SetToolbarPlacement' and no extension method 'SetToolbarPlacement' accepting a first argument of type 'IPlatformElementConfiguration' could be found (are you missing a using directive or an assembly reference?)

But it occur with Xamarin Live, when i build on device, everything fine.

@babman92 Xamarin Live Player is a preview technology with a number of limitations. If it is working on devices, this is probably not a problem with Xamarin.Forms.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hudhud picture Hudhud  ·  3Comments

sonic1015 picture sonic1015  ·  3Comments

EmilAlipiev picture EmilAlipiev  ·  3Comments

simontocknell picture simontocknell  ·  3Comments

joseluisct picture joseluisct  ·  3Comments