BitmapImage.CacheOption Propiedad

Definición

Obtiene o establece el objeto BitmapCacheOption que se va a usar para esta instancia 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

Valor de propiedad

que BitmapCacheOption se usa para .BitmapImage El valor predeterminado es Default.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer el CacheOption de un BitmapImage mediante código.

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

Comentarios

Establezca en CacheOptionBitmapCacheOption.OnLoad si desea cerrar una secuencia usada para crear .BitmapImage La opción de caché predeterminada OnDemand conserva el acceso a la secuencia hasta que se necesita la imagen y el recolector de elementos no utilizados controla la limpieza.

Información de la propiedad dependency

Elemento Value
Campo identificador CacheOptionProperty
Propiedades de metadatos establecidas en true Ninguno

Se aplica a

Consulte también