Dear All
i have a listview in each cell there is an icon, but when i open list some cells show icon and some does not show. this icon has binding on tab it should show same size another icon. (by default it should show Active icon and when tab on that it will be hidden and incative icon should appear) below is xamal code for listview.
<ListView HorizontalOptions="FillAndExpand" CachingStrategy="RecycleElement" SelectionMode="None" HasUnevenRows="True" BackgroundColor="Transparent" ItemsSource="{Binding Data}" VerticalOptions="FillAndExpand"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid Margin="0,5,0,5" BackgroundColor="Transparent"> <Grid.ColumnDefinitions> <ColumnDefinition Width="8*" /> <ColumnDefinition Width="45*" /> <ColumnDefinition Width="30*" /> <ColumnDefinition Width="20*" /> </Grid.ColumnDefinitions> <Label VerticalOptions="Center" FontAttributes="Bold" Grid.Column="0" Text="{Binding SerialNumber}" BackgroundColor="Transparent"/> <Label VerticalOptions="Center" FontAttributes="Bold" Grid.Column="1" Text="{Binding Name}" BackgroundColor="Transparent"/> <Frame Grid.Column="2" BackgroundColor="Black" CornerRadius="5" Padding="0" HeightRequest="36" IsClippedToBounds="true" > <Button BackgroundColor="Black" HorizontalOptions="CenterAndExpand" Command="{Binding ProfileCommand}" VerticalOptions="StartAndExpand" TextColor="Yellow" Text="Profile"/> </Frame> <Frame Grid.Column="3" BackgroundColor="Transparent" CornerRadius="5" Padding="0" HeightRequest="25" IsClippedToBounds="true" IsVisible="{Binding ShowActiveImage}" > <Image BackgroundColor="Transparent" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" IsVisible="{Binding ShowActiveImage}" Source="{u:ImageResource CricApp.Images.active.png}" Aspect="AspectFit"> <Image.GestureRecognizers> <TapGestureRecognizer /> <TapGestureRecognizer Command="{Binding PlayerActiveCommand}" /> </Image.GestureRecognizers> </Image> </Frame> <Frame Grid.Column="3" BackgroundColor="Transparent" CornerRadius="5" Padding="0" HeightRequest="25" IsClippedToBounds="true" IsVisible="{Binding HideActiveImage}" > <Image BackgroundColor="Transparent" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" IsVisible="{Binding HideActiveImage}" Source="{u:ImageResource CricApp.Images.inavtive.png}" Aspect="AspectFit"> <Image.GestureRecognizers> <TapGestureRecognizer /> <TapGestureRecognizer Command="{Binding PlayerInactiveCommand}" /> </Image.GestureRecognizers> </Image> </Frame> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
Answers
Show the method which loads image
private void PlayerInactive()
{
if (HideActiveImage == true)
{
ShowActiveImage = true;
HideActiveImage = false;
}
MessagingCenter.Send(this, MessengerKey.saveplayertodb);
}
Try to change your xaml to:
Your ViewModel for list item must be: