0

Trying to build a Slider menu I´m using this docu coming from official Xamarin. MasterPageDetail

Quite odd, it´s not working. VS2015 intellense recognized me MasterDetailPage (my class is inheriting from it), but when I´m trying to launch the app, next error appears:

The type or namespace name 'MasterPageDetail' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)

What it happens? Do you know of any simply working demo? I´m using this question as reference, but I´m not getting it works... Slider

Some answer uses MasterPageDetail, another one implemented the solution in app (class) and I need to do it in a ContentPage

Thanks mates.

EDITED: I´m using Xamarin.Forms and I imported it and I don´t have any class called like this (MasterPageDetail)... Quite odd, it sounds like a stupid thing but I can´t see it.

Community
  • 1
  • 1
Kenzo_Gilead
  • 2,187
  • 9
  • 35
  • 60

3 Answers3

0

MasterDetailPage is class from Xamarin.Forms if you have class with the same name then it may be a conflict.

Here are some useful links:

https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/master-detail-page/

https://developer.xamarin.com/api/type/Xamarin.Forms.MasterDetailPage/

You can also download my Example from my Github:

https://github.com/15mgm15/XamarinForms-MasterDetailPage-Recipe

Mario Galván
  • 3,964
  • 6
  • 29
  • 39
  • Hi @Mario Galván. Nope, I´m using Xamarin.Forms and I imported it and I don´t have any class called like this... Quite odd, it sounds like a stupid thing but I can´t see it. – Kenzo_Gilead Sep 21 '16 at 06:56
0

I got it.

Finally I clean all project and started a code from zero using the next example (adding just MasterPageItem.cs, piece of cake):

Working MasterDetailDemo

I improved the demo by my own, creating a Master Page Detail where Master´s items bind specific generic page, it will be fill with its own attributes whose depends of id passed to the page´s constructor.

Github Slider Menu improved demo

Hoping it helps...

Kenzo_Gilead
  • 2,187
  • 9
  • 35
  • 60
0
  • There's a simple way to create a MasterDetailPage using XAML, first of all you need to create a page which will contains the MasterDetailPage and a SecondPage which will contains a DetailPage, by doing this, you need to change your hierarchy of this page to MasterDetailPage, and finally load a SecondPage inside of MasterDetailPage.

  • In your project Create a New Page - MenuPage and change the Page Type ContentPage to MasterDetailPage

    <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
         BackgroundColor="White"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="YourProject.MenuPage">
    </MasterDetailPage>
    
  • Then go to your MenuPage.cs and change the hierarchy to MasterDetailPage too.

    public partial class MenuPage : MasterDetailPage
    {
       public ChatPage()
       {
           InitializeComponent();
       }
    }
    
  • Go back to your XAML page - MenuPage and add this :

       <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="YourProjectName.MenuPage">
    
    <MasterDetailPage.Master>
      <ContentPage  Title="Menu">
       <StackLayout Orientation="Vertical">
          <!--Here goes your Menu Items-->
         <Button Text="MyFirstButton"/>
         <Button Text="MySecondButton"/>
         <Button Text="MyThirdButton"/>
       </StackLayout>
     </ContentPage>
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
      <local:SecondPage/>
    </MasterDetailPage.Detail>
    </MasterDetailPage>
    
  • And finally you need to add a reference to your DetailPage

       <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="YourProjectName.MenuPage"
         <!-- Add this line to refer your DetailPage, `SecondPage`-->
         <!-- put your namespace and repeat in assembly -->
         xmlns:local="clr-namespace:YourProjectName;assembly=YourProjectName">
       </MasterDetailPage>
    

I hope its helps you!