In my AppShell.xaml.cs page I can easily access the FlyoutItems of the Shell:
accountFlyoutItem.IsEnabled = false;
accountFlyoutItem.IsVisible = false;
However, how do you access these from another page? The only way I found was to try to iterate through the "Shell.Current.FlyoutItems". Is there a simpler way I'm missing?
Shell.Current.CurrentItem is used to get the current selected flyout .
If we want to access specific FlyoutItem after you named it in xaml (<FlyoutItem x:Name="a">) , we can get it from the following two ways
AppShell and assign the value in constructor. public ShellItem AItem;
public AppShell()
{
InitializeComponent();
RegisterRoutes();
BindingContext = this;
AItem = a;
}
//In another page
var item = (Shell.Current as AppShell).AItem;
public ShellItem GetA()
{
return a;
}
//In another page
var item = (Shell.Current as AppShell).GetA();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With