/ Published in: XML
Xamarin Forms ViewCell Xaml snippet
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<DataTemplate x:Key="itemTemplate"> <ViewCell> <ViewCell.View> <StackLayout Spacing="0" Padding="10,5,10,5" Orientation="Horizontal" HorizontalOptions="FillAndExpand"> <CircleImage Source="{Binding ImageSource}" BorderColor="{x:Static App.BrandColor}" BorderThickness="2" HeightRequest="50" WidthRequest="50" Aspect="AspectFill" HorizontalOptions="Center" VerticalOptions="LayoutOptions.Center" /> <StackLayout Spacing="0" Padding="10,0,0,0" HorizontalOptions="FillAndExpand"> <Label Text="{Binding Name}" FontFamily="HelveticaNeue-Medium" FontSize="18" TextColor="Black" /> <StackLayout Orientation="Horizontal"> <Label Text="{Binding Distance, StringFormat='{0} Miles Away'" FontAttributes="Bold" FontSize="12" TextColor="#666" /> <Image Source="online.png" HeightRequest="8" WidthRequest="8" IsVisible="{Binding ShouldShowAsOnline}" /> <Label Text="Online" TextColor="{x:Static App.BrandColor}" FontSize="12" IsVisible="{Binding ShouldShowAsOnline}" /> <Image Source="offline.png" HeightRequest="8" WidthRequest="8" IsVisible="{Binding ShouldShowAsOffline}" /> <Label Text="5 hours ago" TextColor="#ddd" FontSize="12" IsVisible="{Binding ShouldShowAsOffline}" /> </StackLayout> <StackLayout Spacing="3" Orientation="Horizontal"> <Image Source="star.png" HeightRequest="12" WidthRequest= "12" /> <Label Text="{Binding Stars}" FontSize="12" TextColor="Gray" /> </StackLayout> </StackLayout> </StackLayout> </ViewCell.View> </ViewCell> </DataTemplate> <ListView ItemsSource="{Binding Data}" ItemTemaplate="{StaticResource itemTemplate}" HasUnevenRows="True" SeparatorColor="#ddd" />