Controls not showing in masterdetail Page

KannanKrishKannanKrish INMember
edited July 2018 in Xamarin.Forms

I have an issue, my controls(button, entry) not showing when I am using navigation page but toolbar and menu showing. Without the navigation page, the controls appear but the menu disappears.
In App.cs

public App() => MainPage = new RootPage();

In RootPage.cs

class RootPage : MasterDetailPage
{
.....
Detail =new NavigationPage(new MathInputPage());
....
void OnItemSelectedAsync(object sender, SelectedItemChangedEventArgs e)
{
    .....
     Detail.Navigation.PushAsync((Page)Activator.CreateInstance(item.TargetType));
    ......
}
}

Above code, the menu, as well as the back button, is shown. But controls not showing.

Then I altered this code into
In RootPage.cs

class RootPage : MasterDetailPage
{
.....
Detail =new MathInputPage();
....
void OnItemSelectedAsync(object sender, SelectedItemChangedEventArgs e)
{
    .....
     Detail=(Page)Activator.CreateInstance(item.TargetType);
    ......
}
}

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Have you checked this sample : https://developer.xamarin.com/samples/xamarin-forms/Navigation/MasterDetailPage/

    BTW, for better troubleshooting , you can provide a simple sample to us .

  • KannanKrishKannanKrish INMember

    The Sample Code attached below. I follow the Instructions correctly. I tried another project it's working without any errors. I don't know where are the errors.

  • BillyLiuBillyLiu Member, Xamarin Team Xamurai

    @KannanKrish

    I have downloaded your project, but it couldn't be run on my side. I copy your code to my local project, but can't reproduce your issue, the controls always appear.
    I think you could try to set a break point in your detail page's constructor to debug.
    And you may try to use following code for navigation:

      Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
    
Sign In or Register to comment.