Im trying to loop trhough a ListView, because I want to set "x:Name="lblEstatus"in different color depending on the object content. How can I access to the datatemplate elements of my list view to change the color ?
foreach (var item in myLista.ItemsSource)
{
//I loop the list with this, but how to access each viewcell ?
// I tried to make this: to get the view but not possible
// (ViewCell) test = ...
}
// This is my XAML code for the list view
<ListView x:Name="myLista" HasUnevenRows="true" Margin="0,5,0,5" SeparatorColor="LightGray" VerticalOptions="FillAndExpand" RefreshControlColor="#30AAEA">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Tapped="ViewCell_Tapped">
<StackLayout Orientation="Vertical" HeightRequest="105">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Spacing="10" Margin="0,5,0,0">
<Label Text="EFO: " HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15" x:Name="lblClienProve"/>
<Label Text="{Binding sRFC}" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/>
<Label x:Name="lblEstatus" Text="| Estatus:" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/> // change this color depending object value
<Label Text="{Binding sEstatus}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15" Margin="5,0,5,0"/>
</StackLayout>
<BoxView HeightRequest="2" WidthRequest="250" Color="LightSlateGray" HorizontalOptions="Center"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Spacing="10" Margin="0,5,0,0">
<Label Text="Contribuyente: " HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/>
<Label Text="{Binding sContribuyente}" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/>
</StackLayout>
<StackLayout Spacing="50" HorizontalOptions="Center">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Spacing="10" Margin="0,5,0,0">
<Label Text="{Binding sNotifica}" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/>
<Label Text=" | " HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15"/>
<Label Text="{Binding sLeido}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" FontSize="15" Margin="5,0,5,0"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>