【发布时间】:2020-04-23 14:36:50
【问题描述】:
我是 Xamarin Forms 的新手。
我想在完成特定阶段后在我的应用中启用ShellSection(标签)。
目前我使用AppShell 类来处理导航控件(目前没有启用 PageOneTab)-
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:MyApp="clr-namespace:MyApp"
x:Class="MyApp.AppShell"
FlyoutBehavior="Disabled"
Navigating="Handle_Navigating">
<ShellItem>
<ShellSection x:Name="HomeTab" Icon="home">
<ShellContent>
<MyApp:HomePage/>
</ShellContent>
</ShellSection>
<ShellSection x:Name="PageOneTab" x:FieldModifier="public" IsEnabled="False">
<ShellContent>
<MyApp:PageOnePage/>
</ShellContent>
</ShellSection>
</ShellItem>
</Shell>
在HomePage ContentPage 我有一个按钮点击-
public HomePage()
{
InitializeComponent();
}
private async void HomePageButton_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new HandlingPage());
}
而在我的HandlingPageContentPage 基于结果,我想启用ShellSectionPageOneTab。
public HandlingPage()
{
InitializeComponent();
// do stuff....
// then set -
StatusTab.IsEnabled = true;
}
我认为通过将x:FieldModifier="public" 添加到控件中,我可以从HandlingPage 访问它,但是它不可用,事实上,我认为目前我唯一可以访问控件的地方是在后面的代码中AppShell.xaml.cs 通过执行 StatusTab.IsEnabled = true;。
我相信这可能归结为BindingContext,但不确定。
【问题讨论】:
标签: c# xamarin.forms