2011-02-23 137 views
5

我發現在BitmapImage上設置RequestCachePolicy屬性對ImageSource設置爲BitmapImage的此實例時如何下載位圖沒有影響。爲什麼BitmapImage RequestCachePolicy會被忽略?

例如,如果我將RequestCachePolicy設置爲CacheOnly,我預計不會發生任何互聯網流量 - 只應從緩存中檢索指定的圖像。但是,相反,我看到的請求正在向服務器發出下載一個圖像:

source = new BitmapImage(bmi.UriSource, 
    new RequestCachePolicy(RequestCacheLevel.CacheOnly)); 
// An image gets downloaded! 

如果我的方式我希望設置HttpWebRequest靜態DefaultCachePolicy屬性,那麼我的應用程序行爲的變化。即當它設置爲CacheOnly時,不會發生網絡流量。

爲什麼上的RequestCachePolicy屬性沒有我期望的效果?

回答