2010-08-19 41 views
0

我想清除位圖圖像。我都試過C#清除BitmapImage或其實例

uploadImage.Source = null; 

uploadImage.Source = ""; 

這是我用來使圖像的代碼:

// 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; 
+0

'uploadImage'是什麼類型?也許它有一個'.Clear()'方法? – Timwi 2010-08-19 02:05:28

+0

uploadImage是Image類型的。沒有Clear()方法。 – 2010-08-19 05:40:39

回答

0

uploadImage.Source = NULL應該這樣做。你如何檢查Source屬性的值?我建議Mole
如果您依靠您在屏幕上看到的內容,則可能是由於未通知財產更改而導致錯誤。嘗試爲圖像創建DependencyProperty或通過INotifyPropertyChanged接口引發通知的常規屬性。