Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

ListView ViewCell CustomRenderer

$
0
0

I have extended the ImageCell renderer like so

public class MyImageCellRenderer : ImageCellRenderer
    {
        public ImageView ImageView { get; set; }

        protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
        {
            var view = base.GetCellCore(item, convertView, parent, context);
            ImageView = (ImageView)((Android.Views.ViewGroup)view).GetChildAt(0);
            return view;
        }

        protected override void OnCellPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args)
        {
            base.OnCellPropertyChanged(sender, args);
            if(this.Cell == null)
            {
                return;
            }

            if (args.PropertyName == "IsDownloading")
            {
                //Do stuff here
            }
        }
    }

My view looks like this

  <custom:MyImageCell ImageSource="{Binding IsLocal, Converter={StaticResource bti}}"
                                      TextColor="{Binding IsLocal, Converter={StaticResource btc}}"
                                      Text="{Binding Text}"
                                      Detail="{Binding Detail}"
                                      IsDownloading="{Binding IsDownloading}"
                                      DetailColor="White"/>

Then in my on item tapped, I set the item.IsDownloading to true like so

valuation.IsDownloading = true;

Now the problem is, I dont know what to call for my view to be updated (this is in my ViewModel, that implements INotifyPropertyChanged). I tried calling OnPropertyChanged("Items") and OnPropertyChanged("Item") and OnPropertyChanged("IsDownloading"), but none of them trigger the OnCellPropertyChanged in my custom renderer.

I am lost as what to do next.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>