Xamarin.Forms Projects
上QQ阅读APP看书,第一时间看更新

Touching up the ListView

The ListView could use a couple of minor changes. The first change is formatting the due-date string to a more human, readable format, and the second is to change the color of the completed label to a nice green tint:

  1. Open up Views/MainView.xaml.
  2. Locate the labels that bind Item.Due and Item.Completed in the ListView:
<Label Grid.Column="1"
Grid.Row="1"
Text="{Binding Item.Due, StringFormat='{0:MMMM d, yyyy}'}"
FontSize="Micro" />

<Label Grid.Column="1"
Grid.Row="1"
HorizontalTextAlignment="End"
Text="Completed"
IsVisible="{Binding Item.Completed}"
FontSize="Micro"
TextColor="{StaticResource CompletedColor}" />

We added a string formatting in the binding to format the date using a specific format. In this case, the 0:MMMM d, yyyy format that will display the date as a string in the format of May 5, 2019.

We also added a text color to the Completed label that is only visible if an item is completed. We do this by referencing our dictionary in App.xaml.