我的PCL在MyProject.Views.MainPage中启动,这是它的源代码:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyProject.Views.MainPage">
<Label Text="Hello"/>
<MasterDetailPage.Master>
<ContentPage>
<ContentPage.Content BackgroundColor="Gray" Title="MasterPage">
<StackLayout Margin="5, 30, 5, 5">
<Label Text="Master page"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<ContentPage Padding="10">
<ContentPage.Content>
<StackLayout Margin="5, 30, 5, 5">
<Label Text="Detail page"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Detail>
我没有警告也没有错误,但是当我执行应用程序时,我只看到一个空白页面。
答案 0 :(得分:0)
我发现了两个错误:
MasterDetailPage
标记BackgroundColor="Gray" Title="MasterPage"
这些属性在ContentPage
中可用,您在其他属性(ContentPage.Content
)中使用它们因此,如果您进行这些更改,您将获得与此类似的内容:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage
x:Class="Test.Pages.MasterDetailPage1"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Label Text="Hello" />
<MasterDetailPage.Master>
<ContentPage Title="Master" BackgroundColor="Gray">
<StackLayout Margin="5,30,5,5">
<Label Text="Master page" />
</StackLayout>
</ContentPage>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<ContentPage Padding="10">
<ContentPage.Content>
<StackLayout Margin="5,30,5,5">
<Label Text="Detail page" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
我希望这可以帮到你。