0

I have a controller class that returns some images as WriteableBitmap. I use that lib in my WPF app that should refresh the Image immediately. The problem is, nothing happens when I change its Source :/

private void Csm_OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
{
   WriteableBitmap bitmap = ((Csm) sender).Bitmap;
   Preview.Source = bitmap;
}

How to change the code inside to refresh the image? Sometimes event occurs about 10-20 times for second, so it works almost like video preview.

Nickon
  • 9,652
  • 12
  • 64
  • 119
  • A stupid question, but have you verified that the bitmap returned is actually valid? – Mark Hall Dec 25 '12 at 18:51
  • Why stupid? The control doesn't refresh when I change the source so I wanna know why and how to correct this. Btw. `Preview` is a WPF `Image` control. Yes, it is valid. – Nickon Dec 25 '12 at 19:02
  • It was stupid because, you probably checked it already. but the next question is what type is `((Csm)sender).Bitmap` a bitmap or a writeable bitmap? – Mark Hall Dec 25 '12 at 19:05
  • I know that the bitmap is good, because I saved some PNG files to check it. But it doesn't work when I want to display it in `Image` control. – Nickon Dec 25 '12 at 19:07
  • Instead of creating an intermediate WriteableBitmap, try assigning your ((Csm)sender).Bitmap directly to it see what happens then – Mark Hall Dec 25 '12 at 19:10

0 Answers0