Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Error trying to create master details page

$
0
0

Severity Code Description Project File Line Suppression State
Error CS0263 Partial declarations of 'MainPage' must not specify different base classes App3 D:\DEVELOPMENT\temp workspace\App3\App3\App3\MainPage.xaml.cs 10 Active
Error CS0029 Cannot implicitly convert type 'App3.MainPage' to 'Xamarin.Forms.Page' App3 D:\DEVELOPMENT\temp workspace\App3\App3\App3\App.xaml.cs 16 Active

I'm trying to create a hamburger menu using master details page, like in the GitHub sample...but when I changes MainPage base class from ContentPage to MasterDetailPage like this, I get the errors above

MY CODE

public partial class MainPage : MasterDetailPage
{
    public MainPage()
    {
        InitializeComponent();
    }
}

}

GitHub SAMPLE CODE

public partial class MainPage : MasterDetailPage
{
    public MainPage()
    {
        InitializeComponent();

        masterPage.ListView.ItemSelected += OnItemSelected;

        if (Device.RuntimePlatform == Device.UWP)
        {
            MasterBehavior = MasterBehavior.Popover;
        }
    }

    void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        var item = e.SelectedItem as MasterPageItem;
        if (item != null)
        {
            Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
            masterPage.ListView.SelectedItem = null;
            IsPresented = false;
        }
    }
}

Honestly I don't understand how to do this....there is no step by step guide here at all how to create the navigation using master detail page. Just a bunch of code. Plus all the samples online are one or two years old - I don't even know if they are relevant for the lasts version.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>