首页 > 解决方案 > 我的 Xamarin Forms 界面不显示任何控件或属性

问题描述

我正在使用 Genymotion 为 android 模拟器执行 Xamarin 表单应用程序,问题是它没有显示我的 XAML 页面的任何控件或属性,如您在此屏幕截图中所见。我不记得更改任何相关内容,所以我不知道发生了什么或为什么发生,知道如何解决这个问题吗?

XAML 代码:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="XamForms.MainPage">

    <MasterDetailPage.Detail>
        <ContentPage>
            <StackLayout
        BackgroundColor="Red">
                <Button
            BackgroundColor="Aqua"></Button>
            </StackLayout>
        </ContentPage>
    </MasterDetailPage.Detail>
    <MasterDetailPage.Master>
        <ContentPage>

        </ContentPage>
    </MasterDetailPage.Master>
</MasterDetailPage>

XAML.cs 页面:

namespace XamForms
{
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : MasterDetailPage
    {
        public MainPage()
        {
            BindingContext = new MainPageViewModel();
        }
    }
}

如果您需要更多信息,我会在看到您的请求后立即提供,谢谢大家的时间,祝您有美好的一天。

标签: c#xamarinxamarin.formsgenymotion

解决方案


从未使用过 Genymotion(一直使用物理设备),但我注意到在您的 .cs 页面中,您错过了一个电话,InitializeComponent();我愿意打赌这是问题所在,否则我一眼看上去一切都很好。

虽然,我也注意到您的母版页只有一个空的 ContentPage,但我想知道这是否是问题的一部分


推荐阅读