Xamarin Forms ViewCell Xaml snippet


/ Published in: XML
Save to your folder(s)

Xamarin Forms ViewCell Xaml snippet


Copy this code and paste it in your HTML
  1. <DataTemplate x:Key="itemTemplate">
  2. <ViewCell>
  3. <ViewCell.View>
  4. <StackLayout Spacing="0" Padding="10,5,10,5" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
  5. <CircleImage Source="{Binding ImageSource}" BorderColor="{x:Static App.BrandColor}" BorderThickness="2" HeightRequest="50"
  6. WidthRequest="50" Aspect="AspectFill" HorizontalOptions="Center" VerticalOptions="LayoutOptions.Center" />
  7. <StackLayout Spacing="0" Padding="10,0,0,0" HorizontalOptions="FillAndExpand">
  8. <Label Text="{Binding Name}" FontFamily="HelveticaNeue-Medium" FontSize="18" TextColor="Black" />
  9. <StackLayout Orientation="Horizontal">
  10. <Label Text="{Binding Distance, StringFormat='{0} Miles Away'" FontAttributes="Bold" FontSize="12" TextColor="#666" />
  11. <Image Source="online.png" HeightRequest="8" WidthRequest="8" IsVisible="{Binding ShouldShowAsOnline}" />
  12. <Label Text="Online" TextColor="{x:Static App.BrandColor}" FontSize="12" IsVisible="{Binding ShouldShowAsOnline}" />
  13. <Image Source="offline.png" HeightRequest="8" WidthRequest="8" IsVisible="{Binding ShouldShowAsOffline}" />
  14. <Label Text="5 hours ago" TextColor="#ddd" FontSize="12" IsVisible="{Binding ShouldShowAsOffline}" />
  15. </StackLayout>
  16. <StackLayout Spacing="3" Orientation="Horizontal">
  17. <Image Source="star.png" HeightRequest="12" WidthRequest= "12" />
  18. <Label Text="{Binding Stars}" FontSize="12" TextColor="Gray" />
  19. </StackLayout>
  20. </StackLayout>
  21. </StackLayout>
  22. </ViewCell.View>
  23. </ViewCell>
  24. </DataTemplate>
  25.  
  26. <ListView ItemsSource="{Binding Data}" ItemTemaplate="{StaticResource itemTemplate}" HasUnevenRows="True" SeparatorColor="#ddd" />

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.