-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ページを使用してはならない
。 –
私はそれを試みたが、あまり助けにはならない。 – TigerLionCheetah
MenuPageの読み込み方法は?コードを表示してください。 –