【发布时间】:2016-08-03 09:50:20
【问题描述】:
我正在使用 Xamarin 表单,在我的列表视图中单击元素后,我不想显示它的详细信息。它将打开一个包含详细信息的新视图。我不知道如何将整个对象绑定到视图,以便轻松使用他的属性。
这是我的代码:
public partial class ContactDetailPage : ContentPage
{
public ContactDetailPage(Agency agencyItem)
{
InitializeComponent();
// The agencyItem is get from a list view
// HERE I suppose I need to bind the agencyItem to the view ?
}
}
这是我展示代理的详细视图:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Project.ContactDetailPage">
<ContentPage.Content>
<StackLayout Spacing="0">
<Label Text="{Binding agency.name}" FontSize="Micro" LineBreakMode="TailTruncation" />
<Label Text="{Binding agency.address}" FontSize="Micro" LineBreakMode="TailTruncation" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
如何将视图绑定到 AgencyItem 以显示它?
【问题讨论】:
标签: c# xaml listview xamarin xamarin.forms