【问题标题】:My Xamarin Forms interface does not show any control or properties我的 Xamarin Forms 界面不显示任何控件或属性
【发布时间】:2023-03-13 07:47:01
【问题描述】:

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

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();
        }
    }
}

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

【问题讨论】:

  • 你在哪里调用 InitializeComponent();在那个构造函数中?
  • @SomeStudent 原来是这个问题,我不小心把它删了,非常感谢你的回答(:

标签: c# xamarin xamarin.forms genymotion


【解决方案1】:

从未使用过 Genymotion(一直使用物理设备),但我注意到在您的 .cs 页面中您错过了对 InitializeComponent(); 的呼叫我愿意打赌这是问题所在,否则一切对我来说似乎都很好一眼。

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

【讨论】:

    猜你喜欢
    • 2014-09-13
    • 2020-07-28
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多