Xaml MasterDetailPage显示空白页
我的PCL从MyProject.Views.MainPage开始,这是它的源代码:Xaml MasterDetailPage显示空白页,xaml,xamarin,Xaml,Xamarin,我的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="MyPro
<?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>
我没有警告也没有错误,但当我执行应用程序时,我只看到一个空白页。我发现两个错误:
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>
我希望这能帮助你