-3

So I'm trying to do binding with a list of bitmapImage using async-await, but for some reason I don't see the images on the UI.

In the loop where I'm trying to update the property, when I do:

ImageSource = imageList[2];

or any other number between 0 to 9 then the image is shown in the UI screen.

here is part of my code until the loop where the binding doesn't happend:

EDIT: this was the problam:

    private BitmapImage imageSource = null;
    public BitmapImage ImageSource
    {
        get
        {
            return imageSource;
        }
        set
        {
            imageSource = value;
            // Call OnPropertyChanged whenever the property is updated
            OnPropertyChanged("MessagePerSec");
        }
    }
pp-man
  • 59
  • 1
  • 6

1 Answers1

2

I see one problem straight off. You have the wrong string:

public BitmapImage **ImageSource**
{
    get
    {
        return imageSource;
    }
    set
    {
        imageSource = value;
        // Call OnPropertyChanged whenever the property is updated
        OnPropertyChanged("**MessagePerSec")**;
    }
}

MessagePerSec instead of ImageSource. Which is itself a bad name by the way.

Andy
  • 11,864
  • 2
  • 17
  • 20
  • 1
    Unless you're somehow stuck using .net3.5 you should use the implementation of inotifypropertychanged in the msdn example. That uses callermembername to work out the name of the property and totally obviates writing the wrong "magic" string. nameof() is another alternative. – Andy Apr 27 '18 at 19:44