Listview image not refresing ?

qwdqw




The picture must change after a tapgesture event, but the time you make left and right will change. I do not understand why.
code example :
https://paste.ubuntu.com/p/wgPPXKrJdk/
 



1 Reply

DB Dinesh Babu Yadav Syncfusion Team March 30, 2018 02:40 AM UTC

Hi Alperen, 
 
Thank you for using Syncfusion Products.  
 
Based on the given information and code example, we have tried to replicate the reported issue at our end with similar scenario i.e., changing the image in the data model class by tapping the listview item at runtime as like below code example. But the image is refreshed as expected at runtime. 
 
Code Example[C#]: 
private void TapGestureRecognizer_Tapped(object sender, EventArgs e) 
{ 
   var itemdata = (sender as Grid).BindingContext as MusicInfo; 
 
   if (itemdata == null) 
       return; 
 
   itemdata.IsSelected = !itemdata.IsSelected; 
 
   if (itemdata.IsSelected) 
       itemdata.SelectedImage = ImageSource.FromResource("CustomSelection.Images.Selected.png"); 
   else 
       itemdata.SelectedImage = ImageSource.FromResource("CustomSelection.Images.NotSelected.png"); 
} 
  
We suspect that the issue may occur due to the data model class may not respond the property changes at runtime. So, we highly recommend you to implement the INotifyPropertyChanged interface in your model class as like below code example to respond the property changes which has been documented in our UG documentation below. 
 
  
Code Example[C#]: 
public class MusicInfo : INotifyPropertyChanged 
{ 
  private ImageSource selectedImage; 
 
  public ImageSource SelectedImage 
  { 
    get { return selectedImage; } 
    set 
    { 
       selectedImage = value; 
       this.RaisePropertyChanged("SelectedImage"); 
    } 
  } 
 
  public event PropertyChangedEventHandler PropertyChanged; 
 
  private void RaisePropertyChanged(String name) 
  { 
     if (PropertyChanged != null) 
         this.PropertyChanged(this, new PropertyChangedEventArgs(name)); 
  } 
} 
 
For your reference, we have attached the sample with above code example and you can download it from the below link. 
 
 
Could you please check with the above sample and code examples? If the issue still persists, we suggest you to share the XAML and its code behind page, data model and view model classes where the issue replicates which would help us to analyze the issue better and update you an appropriate solution. 
 
Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Up arrow icon