在我的xaml表格中,我有以下内容:
<ListView x:Name="listView" ItemsSource="{Binding Path=AllResults}" ItemSelected="OnEmployeeListItemSelected" HorizontalOptions="StartAndExpand" HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout VerticalOptions="StartAndExpand">
<Label Text="{Binding Result}" HorizontalOptions="FillAndExpand" Font="{StaticResource fontL}" TextColor="{Binding TestResult, Converter={StaticResource resultMapper}}" />
<Label Text="{Binding Path=StartedOn, StringFormat='dd-MM-yyy @ HH:mm:ss.fff'}" Font="Medium" />
<Label Text="Test went on for {Binding NoOfHours}" Font="Medium"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
AllResults是listview的绑定,它是一个List类型,包含来自DB的基于ORM的对象。
public class Result
{
[PrimaryKey, AutoIncrement]
public int TestID { get; set; }
public DateTime StartedOn { get; set; }
public DateTime EndedOn { get; set; }
public TimeSpan NoOfHours{ get; set; }
public string TestResult{ get; set; }
public Result ()
{
StartedOn = DateTime.Now;
NoOfHours = TimeSpan.Zero;
TestResult = "";
}
}
我需要帮助两件事: