簡體   English   中英

如何在不關閉 C# xamarin forms android 的應用程序的情況下關閉側邊欄?

[英]How could I close my sidebar without closing my app in C# xamarin forms android?

I'm working with C# xamarin forms android and I'm trying to close my sidebar when the user touches de backbuttom but I'm not able to do it. 相反,我的應用程序關閉。

首頁.xaml.cs代碼:

public partial class HomePage : ContentPage
{
    string[] subs;
    public HomePage()
    {
        //NavigationPage.SetHasBackButton(this, false);
        InitializeComponent();
    }
    protected override bool OnBackButtonPressed()
    {
        return true;
    }
}

我的側邊欄 AppShell.xaml.cs 代碼:

public partial class AppShell : Xamarin.Forms.Shell
    {
        public AppShell()
        {
            InitializeComponent();
            nameuser.Title = Preferences.Get("displayName", "Default");
            versionadoAPP.Text = "v" + $"{VersionTracking.CurrentBuild}.{VersionTracking.CurrentVersion}";
        }
        protected override bool OnBackButtonPressed()
        {
            return true;
        }
}

我的應用程序的圖像:

在此處輸入圖像描述

我該如何解決? 非常感謝你!

最簡單的方法是設置彈出顯示屬性。

嘗試這樣的事情:

   Shell.Current.FlyoutIsPresented = false;   

祝你好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM