【发布时间】:2019-11-12 20:41:08
【问题描述】:
我有一个 Xamarin 应用程序,在开发时我们只关注 iphone 的外观。现在我们要在我们的应用程序中为某个页面实现 SplitView。
我已按照以下链接中的步骤进行操作:
https://devblogs.microsoft.com/xamarin/bringing-xamarin-forms-apps-to-tablets/
但它给出了运行时错误:
System.InvalidOperationException:必须在 Master 上设置 Title 属性 页面
我已经在 searchTabletpage.cs 文件中的链接中设置了标题。
public SearchTabletPage()
{
Title = "Details";
this.MasterBehavior = MasterBehavior.Default;
Master = new SearchPage(true);
Detail = new ContentPage()
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children = {
new Label { Text = "Select a Record", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }
}
}
};
((SearchPage)Master).ItemSelected = (searchDetail) =>
{
BusinessDetailPage businessDetail = new BusinessDetailPage(searchDetail.InfogroupId,searchDetail.Distance,searchDetail.FullAddress,searchDetail.Phone);
Detail = businessDetail;
if (Device.RuntimePlatform != Device.UWP)
{
IsPresented = false;
}
};
IsPresented = true;
}
}
请帮助我。 提前致谢。
【问题讨论】:
-
不,我没有创建 masterDetail 页面。我只是创建空类,我只是添加上面显示的代码。 @G.hakim
-
如果您有 Xamarin Forms 4.0 及更高版本,则使用 MasterDetailPage 或 Shell 实现 ios 的拆分视图
-
我有专为 iphone 设计的应用程序,我只需要添加新页面,让它看起来像 ipad 中的 splitview 而已。你能为此提出任何新的解决方案吗?@G.hakim
-
这正是你完成后它会做的事情,多个页面是你试图想出的同一个拆分视图,最好在确定它不是之前尝试一下你想要什么!
标签: xamarin xamarin.forms