BitmapImage.CacheOption Eigenschaft

Definition

Dient zum Abrufen oder Festlegen der BitmapCacheOption Für diese Instanz von 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

Eigenschaftswert

Die BitmapCacheOption für die BitmapImage. Der Standardwert lautet Default.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie sie mithilfe von CacheOption Code festlegen BitmapImage können.

// 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)

Hinweise

Legen Sie fest CacheOption , BitmapCacheOption.OnLoad ob Sie einen Datenstrom schließen möchten, der zum Erstellen des BitmapImageDatenstroms verwendet wird. Die Standardcacheoption OnDemand behält den Zugriff auf den Datenstrom bei, bis das Bild benötigt wird, und die Bereinigung wird vom Garbage Collector verarbeitet.

Informationen zur Abhängigkeitseigenschaft

Element Wert
Bezeichnerfeld CacheOptionProperty
Auf Metadateneigenschaften festgelegt true Nichts

Gilt für:

Weitere Informationen