繁体   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