【发布时间】:2015-10-02 09:53:33
【问题描述】:
我是 Xamarin Forms 和 XAML 的新手,我想填写 <ListView> 预约。我的 XAML 如下所示:
<ListView x:Name="appointmentsView"
ItemsSource="{Binding appointmentList}"
Grid.Row="1"
AbsoluteLayout.LayoutBounds="0.50, 0.2, 1, 0.5"
AbsoluteLayout.LayoutFlags="All">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Label TextColor="Black" Text="{Binding app1}"></Label>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
代码如下所示:
public partial class Home : ContentPage
{
public ObservableCollection<Appointment> appointmentList = new ObservableCollection<Appointment> ();
public Employee Tom { get; set; }
public Appointment app1 { get; set; }
public Home ()
{
InitializeComponent ();
Tom = new Employee("Tom", "Tommen");
app1 = new Appointment(new DateTime(), Tom);
appointmentList.Add(app1);
appointmentsView.ItemsSource = appointmentList;
}
当我调试应用程序时,列表中没有任何内容,如果有人能告诉我我做错了什么,我将不胜感激!
【问题讨论】:
标签: c# xaml xamarin xamarin.forms