簡體   English   中英

Xamarin菜單和ToolbarItem圖標

[英]Xamarin menu with ToolbarItem icon

我想做類似這個例子的事情,但是我做不到。 我嘗試了很多插件,但找不到實現方法。

有人知道或可以告訴我該怎么辦?

當我單擊MasterDetailPage上的一個ToolbarItem時,我想顯示一個顯示彈出菜單。

我的實際應用:

在此處輸入圖片說明

我想要的是:

在此處輸入圖片說明

我想你可以看看SlideOverKit

public SlideDownMenuView ()
{
    InitializeComponent ();

    // You must set HeightRequest in this case
    this.HeightRequest = 600;
    // You must set IsFullScreen in this case, 
    // otherwise you need to set WidthRequest, 
    // just like the QuickInnerMenu sample
    this.IsFullScreen = true;
    this.MenuOrientations = MenuOrientation.TopToBottom;

    // You must set BackgroundColor, 
    // and you cannot put another layout with background color cover the whole View
    // otherwise, it cannot be dragged on Android
    this.BackgroundColor = Color.FromHex ("#D8DDE7");         
}

否則,請在此處輸入鏈接說明

您可以嘗試使用此代碼...

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MasterDetailPage mdpage = new MasterDetailPage();
        mdpage.Master = new ContentPage() { Title = "Master", BackgroundColor = Color.Red };
        ToolbarItem tbi = new ToolbarItem() { Text = "POPUP" };
        tbi.Clicked += async (object sender, System.EventArgs e) => {

            StackLayout sl = new StackLayout() { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start, BackgroundColor = Color.Pink, WidthRequest  = 100, HeightRequest = 200 };
            Rg.Plugins.Popup.Pages.PopupPage mypopup = new Rg.Plugins.Popup.Pages.PopupPage() {BackgroundColor = Color.Transparent };
            mypopup.Content = sl;
            await MainPage.Navigation.PushPopupAsync(mypopup);
        };
        ContentPage detail = new ContentPage() { Title = "Detail", BackgroundColor = Color.Green,  };
        detail.ToolbarItems.Add(tbi);
        mdpage.Detail = new NavigationPage(detail);
        MainPage = mdpage;
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }
}

暫無
暫無

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

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