0

I have one Xamarin Application, while developing we only focused on look and feel for iphone. Now we want to implement SplitView for some page in our application.

I have followed steps given in below link :

https://devblogs.microsoft.com/xamarin/bringing-xamarin-forms-apps-to-tablets/

But it is giving run time error :

System.InvalidOperationException: Title property must be set on Master page

I already set title as given in link inside searchTabletpage.cs file.

public SearchTabletPage()
        {
            Title = "Details";
            this.MasterBehavior = MasterBehavior.Default;

            Master = new SearchPage(true);
            Detail = new ContentPage()
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,

                    Children = {
                        new Label { Text = "Select a Record", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }
                    }

                }

            };

            ((SearchPage)Master).ItemSelected = (searchDetail) =>
            {

                BusinessDetailPage businessDetail = new BusinessDetailPage(searchDetail.InfogroupId,searchDetail.Distance,searchDetail.FullAddress,searchDetail.Phone);
                Detail = businessDetail;
                if (Device.RuntimePlatform != Device.UWP)
                {
                    IsPresented = false;
                }
            };

            IsPresented = true;
        }
    }

Please help me. Thanks in Advance.

PUJA SINGH
  • 45
  • 1
  • 7
  • Possible duplicate of [Hamburger Menu Xamarin Forms (MasterDetailPage)](https://stackoverflow.com/questions/49169049/hamburger-menu-xamarin-forms-masterdetailpage) – FreakyAli Jul 02 '19 at 09:06
  • No , i did not create masterDetail page . i just create empty class and there i i just add code shown above. @G.hakim – PUJA SINGH Jul 02 '19 at 09:12
  • A split view of ios is achieved using MasterDetailPage or Shell if you have Xamarin Forms 4.0 and above – FreakyAli Jul 02 '19 at 09:14
  • I have app which is designed for iphone i just have to add new page so that it should look like splitview in ipad nothing more. can you suggest any new solution for that?@G.hakim – PUJA SINGH Jul 02 '19 at 09:20
  • This is exactly what it will do once you are done with that, the multiple pages are for the same split view that you are trying to come up with, Might as well try it out before deciding it's not what you want! – FreakyAli Jul 02 '19 at 09:30

2 Answers2

0

As the error says, you need to set the title for Master page.

Master = new SearchPage(true)
{
  Title = "Search Page"
};
memsranga
  • 1,088
  • 7
  • 13
  • i tried above solution but now it is throwing exception : **Object reference not set to an instance of an object** in Main.cs file of xamarin.ios Project. – PUJA SINGH Jul 02 '19 at 09:06
  • Edited, the answer, it shouldn;t be empty string, if its still throwing exception, it mostly have nothing to do with MasterDetail page – memsranga Jul 02 '19 at 10:34
  • still throwing exception, can you suggest any other approach to implement ipad splitview design. Note : _i have already app for iphones_ . – PUJA SINGH Jul 02 '19 at 10:38
  • I assume you exception is occurring SearchPage, can you just keep two content pages as Master and Detail pages, helps in zeroing the problem – memsranga Jul 02 '19 at 10:40
0

The tutorial you followed is using Master- Detailed Page, it is implemented by code behind .

Check official sample here : https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/MasterDetailPage/MasterDetailPageNavigation/CS

ColeX
  • 14,062
  • 5
  • 43
  • 240