Using navigation drawer and initial NavigationPage isn't loading a title

JPHochbaumJPHochbaum USMember ✭✭✭
edited September 19 in Xamarin.Forms

I am following this code from github and all my pages are populated with the title in my List.

https://github.com/varunpsr/xamarin-forms/tree/master/MasterDetailPage

''
public class MenuListData : List
{
public MenuListData()
{
this.Add(new MenuItem()
{
Title = "Live View",
TextColor = "Blue",
//IconSource = "contacts.png",
TargetType = typeof(MainView)

        });



        this.Add(new MenuItem()
        {
            Title = "Trades Log",
            TextColor = "Blue",
            //IconSource = "accounts.png",
            TargetType = typeof(TradesLog)
        });

        this.Add(new MenuItem()
        {
            Title = "Settings",
            TextColor = "Blue",
            //IconSource = "leads.png",
            TargetType = typeof(Settings)
        });




    }
}

''

my data array is populated correctly
''
public MenuListView()
{
List data = new MenuListData();
ItemsSource = data;
VerticalOptions = LayoutOptions.FillAndExpand;
BackgroundColor = Color.Transparent;

        var cell = new DataTemplate(typeof(TextCell));
        cell.SetBinding(TextCell.TextProperty, "Title");
        cell.SetBinding(TextCell.TextColorProperty, "TextColor");
        //cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");

        ItemTemplate = cell;
        SelectedItem = data[0];

    }

''
Here is my masterdetail page, and I am very confused as to why the MainView doesn't contain a title on the toolbar, when all other pages do?
''
public RootPage()
{
var menuPage = new MenuPage();

        menuPage.Menu.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as MenuItem);

        Master = menuPage;
        Detail = new NavigationPage(new MainView()) { BarTextColor = Color.Black, Icon = null};
        Detail.BindingContext = new { BarColor = Color.FromRgb(211, 211, 211) };
        Detail.SetBinding(NavigationPage.BarBackgroundColorProperty, new Binding("BarColor"));


    }

    void NavigateTo(MenuItem menu)
    {
        Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);

        Detail = new NavigationPage(displayPage) { BarTextColor = Color.Black, Icon = null};
        Detail.BindingContext = new { BarColor = Color.FromRgb(211, 211, 211) };
        Detail.SetBinding(NavigationPage.BarBackgroundColorProperty, new Binding("BarColor"));


        IsPresented = false;


    }

''

Sign In or Register to comment.