I have taken the approach shown in this Xamarin Forms demo.
However when I create a new MainPage, Master and Detail are both null... I expected at it would be my MenuPage and TabPage respectively. Is this a bug or am I doing something fundamentally wrong?
MainPage:
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ctr="clr-namespace:MyApp.Core.Views;assembly=MyApp.Core"
x:Class="SmartMiner.Core.Views.MainPage"
>
<MasterDetailPage.Master>
<ctr:MenuPage x:Name="MenuPage"/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<ctr:TabPage x:Name="TabPage" />
</MasterDetailPage.Detail>
MenuPage(Master)
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title="Menu"
x:Name="MenuPage"
x:Class="MyApp.Core.Views.MenuPage"
>
<ContentPage.Content>
</ContentPage.Content>
TabPage(Details)
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Core.Views.TabPage"
xmlns:tab="clr-namespace:SmartMiner.Core.Views;assembly=SmartMiner.Core"
Title="Tabs Page"
>
<tab:Tab1 Title="Tab One"/>
<tab:Tab2 Title="Tab Two" />
<tab:Tab3 Title="Tab Three" />
Init
protected override void OnStart(){
var mainPage = new MainPage();
if (Device.RuntimePlatform == Device.iOS)
MainPage = mainPage;
else
MainPage = new NavigationPage(mainPage);
}
The result when inspecting var mainPage is that the properties Master and Detail are null and the designation of MainPage throws an error
"Master and Detail must be set before assigning it to MainPage"