2017-03-09 92 views
0

我想做類似這個例子的東西,但是我做不到。 我嘗試了很多插件,但無法找到實現的方式。帶有ToolbarItem的Xamarin菜單圖標

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

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

我的實際應用:

enter image description here

我想要什麼:

enter image description here

回答

0

我覺得你可以看看到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");   
} 

否則與enter link description here

你可以用這個代碼嘗試...

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 
    } 
} 
+0

我用SlideOverKit顯示在Tabbedpage菜單BottomToTop和工作正常,但不能ASIGN它toptobottom就像你說的,因爲它是一個MasterDetailPage,和我不知道如何實現它。 – kvaldes

+0

你有沒有試過這個插件https://github.com/rotorgames/Rg.Plugins.Popup –

+0

是的,但它不起作用,它顯示不好,並使後窗變暗,我只想顯示一個下拉菜單..這是我的代碼: \t \t \t \t kvaldes