Dynamic updating of a processed WriteableBitmap in a WPF component

Jan 29, 2015 at 4:24 PM
I have a WPF Image control, whose source is bound to a WriteableBitmap in my XAML code and this WriteableBitmap is continuously updated in the code behind. The bitmap is displayed in the image control and the window as long as it's not processed using WriteableBitmapEx methods. If I try to process the image before returning it to the UI control the image doesn't appear anymore.

Here are the code snippets:

XAML:
<Image x:Name="ImageControl" Source="{Binding ImageSource}" Stretch="Uniform" />
Bound method in the code behind:
public ImageSource ImageSource
        {
            get
            {
                return this.bitmap;
            }
        }
The above code works and the image displays properly.

If, however, I modify the last method and do something like:
public ImageSource ImageSource
        {
            get
            {
                return this.bitmap.Crop(20,20,200,200);
            }
        }
then the image doesn't appear anymore.

Anybody has a clue as to why that happens?