We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Bug Inside Listview

Hello I have syncfusion listview and i have some things in listview for example labels backgroundcolor is maroon and when i click it it turns to green I am doing it with command parameter and gesture recognizers but for example if i click 1st label it turn to green but also 4th turns to green too if i click 2nd 5th turns to green too I dont know what should i do. Can anyone help me?

1 Reply

GP Gnana Priya Namasivayam Syncfusion Team November 3, 2018 10:07 AM UTC

Hi Furkan,  
  
Thanks for using Syncfusion support.  
  
We have checked the reported query from our end. We have prepared sample based on your requirement to change label color using tapgesture by command. We have prepared a sample based on your requirement for your reference, please find the sample below.  
  
  
  
<ContentPage>  
  <sync:SfListView>  
       <sync:SfListView.ItemTemplate>  
            <DataTemplate>  
                <Grid>  
                     <Label Text="{Binding BookName}" BackgroundColor="{Binding Color}"FontAttributes="Italic" FontSize="Small" HorizontalOptions="CenterAndExpand">  
                            <Label.GestureRecognizers>  
                                <TapGestureRecognizer Command="{Binding Path=BindingContext.TapCommand,Source={x:Reference Name=listView}}" CommandParameter="{Binding .}" />  
                            </Label.GestureRecognizers>  
                      </Label>  
                </Grid>  
            </DataTemplate>  
        </sync:SfListView.ItemTemplate>  
  </sync:SfListView>  
</ContentPage>  
  
  
You can change background color for label in viewmodel like below :  
  
  
public ICommand TapCommand  
{  
   get { return tapcommand; }  
   set { this.tapcommand = value; }  
}  
public BookInfoRepository()  
{  
   TapCommand = new Command(OnTapped);  
}  
  
private void OnTapped(object obj)  
{  
   var item = obj as BookInfo;  
   item.Color = Color.GreenYellow;  
}  
  
  
  
Please let us know whether sample meets your requirement.  
  
Regards,  
Gnana Priya N  
 


Loader.
Live Chat Icon For mobile
Up arrow icon