在我的 AppShell.xaml.cs 页面中,我可以轻松访问 Shell 的 FlyoutItems:
accountFlyoutItem.IsEnabled = false;
accountFlyoutItem.IsVisible = false;
但是,您如何从另一个页面访问这些?我发现的唯一方法是尝试遍历“Shell.Current.FlyoutItems”。有没有我想念的更简单的方法?
在我的 AppShell.xaml.cs 页面中,我可以轻松访问 Shell 的 FlyoutItems:
accountFlyoutItem.IsEnabled = false;
accountFlyoutItem.IsVisible = false;
但是,您如何从另一个页面访问这些?我发现的唯一方法是尝试遍历“Shell.Current.FlyoutItems”。有没有我想念的更简单的方法?
Shell.Current.CurrentItem
用于获取当前选定的弹出窗口。
如果我们想FlyoutItem
在你在xaml()中命名后访问特定的<FlyoutItem x:Name="a">
,我们可以通过以下两种方式获取
AppShell
并赋值。 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();