c# - 我的 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();
}
}
}
如果您需要更多信息,我会在看到您的请求后立即提供,谢谢大家的时间,祝您有美好的一天。
解决方案
从未使用过 Genymotion(一直使用物理设备),但我注意到在您的 .cs 页面中,您错过了一个电话,InitializeComponent();
我愿意打赌这是问题所在,否则我一眼看上去一切都很好。
虽然,我也注意到您的母版页只有一个空的 ContentPage,但我想知道这是否是问题的一部分
推荐阅读
- python - Jupyter 笔记本异常
- reactjs - 从 react-beautiful-dnd 水平列表中删除单个项目
- r - R ggplot 如何显示两个变量的概率
- python - ImportError:没有名为 utils_datagen 的模块
- typescript - 将类型分配给也被重命名的解构变量
- c# - 在 PageSetupDialog 中设置默认纸张大小
- javascript - 没有为我的输入元素调用 Keyup 处理程序
- python - Python 相对导入“高于顶层”
- scala - Scala trait 可以复制它的子类吗?
- google-analytics - 在 Jekyll 中基于 Google Analytics 显示页面浏览量