views:

39

answers:

1

I would like to clear a bitmap image. I've tried both

uploadImage.Source = null;

and

uploadImage.Source = "";

This is the code I used to make the image:

// BitmapImage.UriSource must be in a BeginInit/EndInit block
BitmapImage myBitmapImage = new BitmapImage();
string curItem = destinationFolder + "\\" + listBox1.SelectedItem.ToString();

myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@curItem);
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
uploadImage.Source = myBitmapImage;
A: 

uploadImage.Source = null should do it. How are you checking the value of the Source property? I'd suggest Mole.
If you are relying on what you see on screen this may be wrong due to property changes not being notified. Try creating a DependencyProperty for the Image or a regular property raising a notification through the INotifyPropertyChanged interface.

Gustavo Cavalcanti