Skip to content

Instantly share code, notes, and snippets.

@DerekCacciotti
Created April 2, 2018 02:53
Show Gist options
  • Save DerekCacciotti/5d3ec673535e8c1c1fa8fc237294e1bb to your computer and use it in GitHub Desktop.
Save DerekCacciotti/5d3ec673535e8c1c1fa8fc237294e1bb to your computer and use it in GitHub Desktop.
A sample Xamarin Forms ListView
<?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="ParkLane.CommentsPage">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="commentslistview" RowHeight="95" VerticalOptions="FillAndExpand" HasUnevenRows="true" HeightRequest="500" WidthRequest="200">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout HorizontalOptions="FillAndExpand" Spacing="5" Orientation="Vertical" VerticalOptions="FillAndExpand" Padding="20">
<Label Text="{Binding StatusID}" x:Name="idtext" IsVisible="false"></Label>
<Label Text="{Binding text}" HorizontalOptions="StartAndExpand" VerticalTextAlignment="Start" x:Name="statustextlabel">
</Label>
<Label Text="{Binding user, StringFormat='Comment by {0}'}" HorizontalTextAlignment="End" Font="11" x:Name="realname"></Label>
<Label Text="{Binding PostDate, StringFormat='Posted on {0:MM/dd/yyyy}'}" HorizontalTextAlignment="Start" Font="11" x:Name="postdate"></Label>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Entry x:Name="commententry" Placeholder="Write your comment here" Grid.Row="0" Grid.Column="0" FontSize="12"></Entry>
<Button x:Name="commentpostbutton" Text="Post" Clicked="Comment_Clicked" Grid.Row="0" Grid.Column="1" WidthRequest="250"></Button>
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment