Xamarin表单ViewCell Xaml片段
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Xamarin表单ViewCell Xaml片段相关的知识,希望对你有一定的参考价值。
Xamarin Forms ViewCell Xaml snippet
<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" />
以上是关于Xamarin表单ViewCell Xaml片段的主要内容,如果未能解决你的问题,请参考以下文章
XAML中的Xamarin.Forms ListView AutoHeight
如何在 Xamarin Forms 的可重用 ViewCell 中绑定命令?