2017-06-27 1 views
-1

ハンバーガーメニューを表示するプロジェクトにコードが実装されていますが、何らかの理由でスライドのメニューが表示されるだけですが(左から右)、ハンバーガー。ここでMasterDetail Pageハンバーガーメニューが表示されない

は私MenuPage.xamlです:

<?xml version="1.0" encoding="utf-8" ?> 
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      x:Class="LoginSystem.Views.MenuPage" 
      xmlns:local="clr-namespace:LoginSystem.Views"> 

    <MasterDetailPage.Master> 
     <ContentPage Title="Menu" > 
      <StackLayout Orientation="Vertical" BackgroundColor="LightBlue"> 
       <Button Text="Calendar" BackgroundColor="Blue" TextColor="White" HorizontalOptions="FillAndExpand" Command="{Binding Calendar_OnClicked}"/> 
       <Button Text="My Profile" BackgroundColor="Blue" TextColor="White" HorizontalOptions="FillAndExpand" Command="{Binding MyProfile_OnClicked}"/> 
       <Button Text="Home" BackgroundColor="Blue" TextColor="White" HorizontalOptions="FillAndExpand" Command="{Binding MyHome_OnClicked}"/> 
       <Button Text="Logout" BackgroundColor="Blue" TextColor="White" HorizontalOptions="FillAndExpand" Command="{Binding Logout_OnClicked}"/> 
      </StackLayout> 
     </ContentPage> 
    </MasterDetailPage.Master> 

    <MasterDetailPage.Detail> 
     <local:MyHomePage/> 
    </MasterDetailPage.Detail> 


</MasterDetailPage> 

そして、ここでは私のMenuPage.csです:

using LoginSystem.Models; 
using LoginSystem.ViewModels; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

using Xamarin.Forms; 
using Xamarin.Forms.Xaml; 

namespace LoginSystem.Views 
{ 
    [XamlCompilation(XamlCompilationOptions.Compile)] 
    public partial class MenuPage : MasterDetailPage 
    { 
     public MenuPage(string email, string password) 
     { 
      InitializeComponent(); 

      NavigationPage.SetHasBackButton(this, false); 
      this.BindingContext = new Menu_vm(email, password); 
     } 

     public MenuPage() 
     { 
      InitializeComponent(); 

      NavigationPage.SetHasBackButton(this, false); 
      this.BindingContext = new Menu_vm(); 
     } 
    } 
} 

あなたは(XAML)でバックグラウンドでページを参照してください:

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:ViewModels="clr-namespace:LoginSystem.ViewModels" 
      xmlns:local="clr-namespace:LoginSystem.Views"  
      x:Class="LoginSystem.Views.MyHomePage" 
      BackgroundColor="Azure" 
      Title="My Home Page"> 

    <ContentPage.Content> 
     <StackLayout> 
      <Label Text="{Binding Welcome}" HorizontalOptions="Center" TextColor="Gold" FontSize="Large"/> 
     </StackLayout> 
    </ContentPage.Content> 
</ContentPage> 

CS:

namespace LoginSystem.Views 
{ 
    [XamlCompilation(XamlCompilationOptions.Compile)] 
    public partial class MyHomePage : ContentPage 
    { 
     public MyHomePage(string email, string password) 
     { 
      InitializeComponent(); 
      NavigationPage.SetHasBackButton(this, false); 
      this.BindingContext = new MyHomePage_vm(email, password); 
     } 

     public MyHomePage() 
     { 
      InitializeComponent(); 
      NavigationPage.SetHasBackButton(this, false); 
     } 
    } 
} 

最後にスクリーンショット:あなたはナビゲーション・ページ内MasterDetailページを使用してはならない

enter image description here

enter image description here

+0

。 –

+0

私はそれを試みたが、あまり助けにはならない。 – TigerLionCheetah

+0

MenuPageの読み込み方法は?コードを表示してください。 –

答えて

0

あなたは以下の変更を試すことができます:

  1. は、ユーザーを認証するため、rootとしてログインページを設定します。ユーザーが認証されると、マスター詳細ページとしてルートを設定します。
  2. 詳細ページから詳細なナビゲーションが必要な場合は、詳細ページをナビゲーションページにラップします。

マスター・ディテール・ページの詳細を読み、提供のサンプルを見て - (偽本、)NavigationPage.SetHasBackButtonを削除するようにしてくださいMaster-Detail Page

関連する問題