Xamarin Forms Invoke IValueConverter on a notification call

Hello,

I have got a list of images shown using a ListView. All the elements properties are tied to a POCO class and they are..

public class Element : INotifyPropertyChanged
    {
public int Id { get; set; }

 public TransmissionStatus TransmissionStatus
        {
            get { return _TransmissionStatus; }
            set
            {
                _TransmissionStatus = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TransmissionStatus"));
            }
        }

public string OriginalFileName { get; set; }

        public string FilePath { get; set; }
}
public enum TransmissionStatus
    {
        Pending = 1,
        Running = 2,
        Paused = 4,
        Successful = 8,
        Failed = 16
    }
}

Now I have got a IValueConverter(which is inside my VM) to make a check if the image has to be enabled/disabled. This is...

public class StateCheckConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var result = false;

            if (value != null)
            {
                var element = value as Element;
                if (element .TransmissionStatus != element .Pending)
                    result = true;
            }

            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }

I have a NotificationCall back when the image is uploaded. I have got a callback method and I change my ObservableCollection accordingly.

Now how can I invoke the IValueConverter so that the UI gets updated?

Thanks.

Sign In or Register to comment.