TechWatching
TechWatching

Reputation: 1547

Is it possible to hide a specific FlyoutItem when using Xamarin Forms Shell?

I am using Xamarin Forms Shell and I want to be able to hide some items of my Flyout depending on some parameters (the current page for instance) but I can't find any method or property to change the visibility of a FlyoutItem.

Is it possible to programmaticaly hide some FlyoutItem (not the complete Flyout just some items) ?

Upvotes: 6

Views: 4468

Answers (5)

stersym
stersym

Reputation: 308

I was searching how i can hide a MenuItem in Shell Flyout because i didn't want to use FlyoutItem. I needed the Clicked event. I managed to hide a MenuItem with:

<MenuItem Text="Arrivals" x:Name="Arrivals" Clicked="MenuItem_Clicked" Shell.FlyoutItemIsVisible="False"/>

Upvotes: 0

this works for me flyoutxname.FlyoutItemIsVisible = false;

where flyoutxname is the x:Name property for the flyoutitem.

<FlyoutItem Title="item title" x:Name="flyoutxname" Icon="byebye.jpg">

source https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/flyout

Upvotes: 0

Azraelz
Azraelz

Reputation: 49

Had the same issue, here is my solution. I created a style, and set that to hidden. Then I update my MenuItem in the backend, depending what is needed.

Style

<Style
            ApplyToDerivedTypes="True"
            Class="MenuItemLayoutStyleHidden"
            TargetType="Layout">
            <Setter Property="IsVisible" Value="False" />
        </Style>

Menu Item

<MenuItem
    x:Name="btnLogout"
    Clicked="btnLogoutClick"
    IconImageSource="icon_about.png"
    StyleClass="MenuItemLayoutStyle"
    Text="Logout" />

Backend Code

if (user.isLoggedIn)
        {
            [email protected]();
            [email protected]("MenuItemLayoutStyle");
        }
        else
        {
            [email protected]();
            [email protected]("MenuItemLayoutStyleHidden");
        }

Upvotes: 0

Neeraj Goel
Neeraj Goel

Reputation: 282

It is possible with Xamarin.Forms 4.8 version. you can use Isvisible attribute to show/hide any flyout item. Please refer below link for more details :

Xamarin.Forms v4.8

GitHub Issue Resolved

Upvotes: 2

Bruno Caceiro
Bruno Caceiro

Reputation: 7199

As of this moment it is not possible, there is a current Issue regarding this.

However, I managed to find another thread, where there might be a solution with dynamic creating flyout items. You can check it here.

Upvotes: 4

Related Questions