BitmapImage.CacheOption 屬性

定義

取得或設定要用於這個 BitmapCacheOption 執行個體的 BitmapImage

public:
 property System::Windows::Media::Imaging::BitmapCacheOption CacheOption { System::Windows::Media::Imaging::BitmapCacheOption get(); void set(System::Windows::Media::Imaging::BitmapCacheOption value); };
public System.Windows.Media.Imaging.BitmapCacheOption CacheOption { get; set; }
member this.CacheOption : System.Windows.Media.Imaging.BitmapCacheOption with get, set
Public Property CacheOption As BitmapCacheOption

屬性值

用於 BitmapCacheOptionBitmapImage。 預設為 Default

範例

下列程式碼範例示範如何使用程式碼來設定 CacheOptionBitmapImage

// Define a BitmapImage.
Image myImage = new Image();
BitmapImage bi = new BitmapImage();

// Begin initialization.
bi.BeginInit();

// Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand;
bi.CreateOptions = BitmapCreateOptions.DelayCreation;
bi.DecodePixelHeight = 125;
bi.DecodePixelWidth = 125;
bi.Rotation = Rotation.Rotate90;
MessageBox.Show(bi.IsDownloading.ToString());
bi.UriSource = new Uri("smiley.png", UriKind.Relative);

// End initialization.
bi.EndInit();
myImage.Source = bi;
myImage.Stretch = Stretch.None;
myImage.Margin = new Thickness(5);
' Define a BitmapImage.
Dim myImage As New Image()
Dim bi As New BitmapImage()

' Begin initialization.
bi.BeginInit()

' Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand
bi.CreateOptions = BitmapCreateOptions.DelayCreation
bi.DecodePixelHeight = 125
bi.DecodePixelWidth = 125
bi.Rotation = Rotation.Rotate90
MessageBox.Show(bi.IsDownloading.ToString())
bi.UriSource = New Uri("smiley.png", UriKind.Relative)

' End initialization.
bi.EndInit()
myImage.Source = bi
myImage.Stretch = Stretch.None
myImage.Margin = New Thickness(5)

備註

CacheOptionBitmapCacheOption.OnLoad 如果您想要關閉用來建立 的資料流程, BitmapImage 請將 設定為 。 預設 OnDemand 快取選項會保留資料流程的存取權,直到需要映射,而且垃圾收集行程會處理清除。

相依性屬性資訊

識別碼欄位 CacheOptionProperty
設定為 的中繼資料屬性 true

適用於

另請參閱