C# Xamarin表单中的访问控制

C# Xamarin表单中的访问控制,c#,xamarin.forms,C#,Xamarin.forms,我是Xamarin表单的新手 一旦某个特定阶段完成,我想在我的应用程序中启用一个外壳部分(选项卡) 目前,我使用AppShell类来处理导航控件(当前未启用PageOneTab)- 在基于结果的我的HandlingPageContentPage中,我想启用ShellSectionPageOneTab public HandlingPage() { InitializeComponent(); // do stuff.... // then set - Stat

我是Xamarin表单的新手

一旦某个特定阶段完成,我想在我的应用程序中启用一个
外壳部分
(选项卡)

目前,我使用
AppShell
类来处理导航控件(当前未启用PageOneTab)-

在基于结果的我的
HandlingPage
ContentPage中,我想启用
ShellSection
PageOneTab

public HandlingPage()
{
    InitializeComponent();

    // do stuff....

    // then set -
    StatusTab.IsEnabled = true;
}
我想通过向控件添加
x:FieldModifier=“public”
我可以从
HandlingPage
访问它,但是它不可用,事实上,我认为当前唯一可以访问控件的地方是
AppShell.xaml.cs
的代码后面,方法是执行
StatusTab.IsEnabled=true
我相信这可能是由于
BindingContext
造成的,但是我不确定。

如果您想更改一个ShellSection的IsEnable状态,我建议您可以使用MessageCenter来执行此操作

我的商品:

 <ShellItem>
    <ShellSection
        x:Name="itempage"
        Title="Browse"
        Icon="tab_feed.png">
        <ShellContent>
            <local:ItemsPage />
        </ShellContent>
    </ShellSection>
    <ShellSection
        x:Name="aboutpage"
        Title="About"
        Icon="tab_about.png"
        IsEnabled="False">
        <ShellContent>
            <local:AboutPage />
        </ShellContent>
    </ShellSection>
</ShellItem>

并订阅AppShell.cs中的消息:

 public AppShell()
    {
        InitializeComponent();

        MessagingCenter.Subscribe<AppShell>(this, "Hi", (sender) =>
        {
            aboutpage.IsEnabled = true;
        });
    }
public AppShell()
{
初始化组件();

MessagingCenter.Subscribe

如果您想更改一个ShellSection的IsEnable状态,我建议您可以使用MessageCenter来执行此操作

我的商品:

 <ShellItem>
    <ShellSection
        x:Name="itempage"
        Title="Browse"
        Icon="tab_feed.png">
        <ShellContent>
            <local:ItemsPage />
        </ShellContent>
    </ShellSection>
    <ShellSection
        x:Name="aboutpage"
        Title="About"
        Icon="tab_about.png"
        IsEnabled="False">
        <ShellContent>
            <local:AboutPage />
        </ShellContent>
    </ShellSection>
</ShellItem>

并订阅AppShell.cs中的消息:

 public AppShell()
    {
        InitializeComponent();

        MessagingCenter.Subscribe<AppShell>(this, "Hi", (sender) =>
        {
            aboutpage.IsEnabled = true;
        });
    }
public AppShell()
{
初始化组件();

MessagingCenter.Subscribe

惊人,这是一种享受。请问使用这种方法是一种良好的设计实践吗?惊人,这是一种享受。请问使用这种方法是一种良好的设计实践吗?
 private void btn1_Clicked(object sender, EventArgs e)
    {
        MessagingCenter.Send<AppShell>(new AppShell(),"Hi");
    }