- Home
- Forum
- Xamarin.Forms
- Listview Item Apperance Question
Listview Item Apperance Question
Hello
I am using SFListView on xamarin forms my question how can i access one item in viewcell on listview codebehind i am sharing my listview below
i want access x:Name="bjk" stacklayout when data is filling and change color i couldnt success if anyone help me i will appricate
thank you
<listview:SfListView x:Name="listView" ItemSize="150" SelectionBackgroundColor="White"
RowSpacing="15" SelectionChanged="ListView_SelectionChanged" ItemAppearing="ListView_ItemAppearing">
<listview:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<border:SfBorder BorderColor="Black" BorderWidth="0" CornerRadius="10,0,10,0" Margin="10,10,10,0" BackgroundColor="White" Padding="3">
<StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<StackLayout Grid.Column="0" BackgroundColor="White" Orientation="Horizontal">
<StackLayout Padding="10">
<StackLayout>
<Label Text="{Binding title}" FontAttributes="Bold" FontSize="Large"/>
</StackLayout>
<StackLayout>
<Label Text="{Binding date}" FontAttributes="Bold"/>
</StackLayout>
</StackLayout>
</StackLayout>
<StackLayout Grid.Column="1" Orientation="Horizontal" HorizontalOptions="End" Margin="0,0,30,0">
<Label Text="" FontSize="30" VerticalTextAlignment="Center">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String" Android="FontAwesome5Free-Solid-900.otf#Font Awesome 5 Free Solid" iOS="Font Awesome 5 Free"/>
</Label.FontFamily>
</Label>
<Label Text="{Binding sensors.Speed}" FontAttributes="Bold" FontSize="Medium" TextColor="Black" FontFamily="{StaticResource BoldFont}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
</StackLayout>
</Grid>
<StackLayout Orientation="Horizontal">
<Label Text="Günlük Mesafe : " FontAttributes="Bold"/>
<Label Text="{Binding sensors.TodaysDistance}"/>
<Label Text="Toplam Mesafe : " FontAttributes="Bold"/>
<Label Text="{Binding sensors.TotalDistance}"/>
</StackLayout>
<StackLayout x:Name="bjk" Orientation="Horizontal" BackgroundColor="Green">
<Label x:Name="lbDurum" Text="Kontak Açık" TextColor="White"/>
<Label x:Name="lbAdres" Text="{Binding address}" TextColor="White"/>
</StackLayout>
</StackLayout>
</border:SfBorder>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</listview:SfListView.ItemTemplate>
</listview:SfListView>
SIGN IN To post a reply.
1 Reply
DY
Deivaselvan Y
Syncfusion Team
March 29, 2019 12:03 PM UTC
Hi Burak,
Thanks for using Syncfusion products.
We have checked the reported query from our side. We would like to inform you that you cann’t access the element inside the ItemTemplate directly from code behind. In order to achieve your requirement, you can bind the model property to BackgroundColor of StackLayout property and change it accordingly when the items fills as per your requirement. We have attached the sample based on your requirement for your reference, please find the sample from below.
Please let us know if you need any further assistance.
Regards,
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
BU Burak
- Mar 28, 2019 02:11 PM UTC
- Mar 29, 2019 12:03 PM UTC