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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bug Inside Listview

Thread ID:

Created:

Updated:

Platform:

Replies:

140691 Nov 1,2018 02:14 PM UTC Nov 3,2018 10:07 AM UTC Xamarin.Forms 1
loading
Tags: SfListView
Furkan
Asked On November 1, 2018 02:14 PM UTC

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?

Gnana Priya Namasivayam [Syncfusion]
Replied On 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  
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;