문제

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;
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top