I tried different methods from existing posts but I am not able to update an image into the Image control. If I execute the code below directly from the view cs, it works fine (so don't pay attention to .Convert method, so the format is ok). However, I am not reaching the image update from another class.
The issue seems to be the OnPropertyChanged event, where the code executes the 'set' of the _displayedImage object properly, but when the 'get' is triggered, the bitmapImage has errors... Why if is the same object?
ViewModel:
//Image displayed
private BitmapImage _displayedImage;
public BitmapImage DisplayedImage
{
get {
return _displayedImage; }
set {
_displayedImage = value;
OnPropertyChanged("DisplayedImage");
}
}
Xaml:
<Image x:Name="ImageViewer" Source="{Binding DisplayedImage}" HorizontalAlignment="Center" VerticalAlignment="Top" Stretch="Fill"/>
Code to update image:
Bitmap bmp= new Bitmap(@"C:\test.jpg");
RunVM.DisplayedImage = Utilities.Instance.Convert(bmp);
Update 1:
When the set is triggered, _displayedImage has the proper content:
After that, when the event is triggered, _displayedImage has errors:


RunVMassigned to theDataContextof the view? Do you observe any data binding error messages in the Output Window in Visual Studio when you debug the application? As a note,Mode=TwoWayon the Source Binding is pointless.ifstatement in the property setter does not make much sense if it does not also contain the OnPropertyChanged call. Add some parentheses, or remove the if statement. Firing PropertyChanged for a property that has not actually changed doesn't hurt.