BitmapImage.CacheOption Propriété

Définition

Obtient ou définit le BitmapCacheOption à utiliser pour cette instance de 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

Valeur de propriété

BitmapCacheOption actuellement utilisé pour le BitmapImage. La valeur par défaut est Default.

Exemples

L’exemple de code suivant montre comment définir le d’un BitmapImage à l’aide CacheOption de code.

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

Remarques

Définissez sur CacheOptionBitmapCacheOption.OnLoad si vous souhaitez fermer un flux utilisé pour créer le BitmapImage. L’option de cache par défaut OnDemand conserve l’accès au flux jusqu’à ce que l’image soit nécessaire et que le nettoyage soit géré par le garbage collector.

Informations sur les propriétés de dépendance

Champ Identificateur CacheOptionProperty
Propriétés de métadonnées définies sur true Aucun

S’applique à

Voir aussi