RenderOptions.SetCachingHint(DependencyObject, CachingHint) Método

Definição

Define o valor da CachingHint propriedade associada a um objeto de dependência especificado.

public:
 static void SetCachingHint(System::Windows::DependencyObject ^ target, System::Windows::Media::CachingHint cachingHint);
public static void SetCachingHint(System.Windows.DependencyObject target, System.Windows.Media.CachingHint cachingHint);
static member SetCachingHint : System.Windows.DependencyObject * System.Windows.Media.CachingHint -> unit
Public Shared Sub SetCachingHint (target As DependencyObject, cachingHint As CachingHint)

Parâmetros

target
DependencyObject

O objeto de dependência sobre o qual definir o valor da CachingHint propriedade.

cachingHint
CachingHint

O novo valor para definir a propriedade.

Exceções

O especificado target é null.

Exemplos

O exemplo a seguir mostra como usar a opção de dica de cache para um DrawingBrush.

DrawingBrush drawingBrush = new DrawingBrush();
            
// Set the caching hint option for the brush.
RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);

// Set the minimum and maximum relative sizes for regenerating the tiled brush.
// The tiled brush will be regenerated and re-cached when its size is
// 0.5x or 2x of the current cached size.
RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5);
RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0);
Dim drawingBrush As New DrawingBrush()

' Set the caching hint option for the brush.
RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache)

' Set the minimum and maximum relative sizes for regenerating the tiled brush.
' The tiled brush will be regenerated and re-cached when its size is
' 0.5x or 2x of the current cached size.
RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5)
RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0)

Observações

Por defeito, WPF não armazena em cache o conteúdo renderizado dos objetos DrawingBrush e VisualBrush. Em cenários estáticos, onde nem o conteúdo nem o uso do pincel na cena mudam, não fazer cache oferece uma vantagem porque poupa memória de vídeo. Quando um pincel com conteúdo estático é usado de forma não estática, o comportamento padrão do WPF é voltar a renderizar todo o conteúdo do pincel a cada frame, mesmo que o conteúdo seja inalterável. Por exemplo, isto acontece quando uma estática DrawingBrush ou VisualBrush está mapeada para a superfície de um objeto 3D em rotação. A re-renderização do conteúdo estático pode ter um impacto negativo no desempenho.

Ao definir a CachingHint propriedade associada do pincel para Cache, pode aumentar o desempenho usando versões em cache dos objetos do pincel em mosaico.

Os CacheInvalidationThresholdMinimum valores das propriedades e CacheInvalidationThresholdMaximum são valores de tamanho relativo que determinam quando o TileBrush objeto deve ser regenerado devido a alterações na escala. Por exemplo, quando a CacheInvalidationThresholdMaximum propriedade está definida para 2.0, a cache para o TileBrush só precisa de ser regenerada quando o seu tamanho exceder o dobro do tamanho da cache atual.

Use este método para definir a CachingHint propriedade anexada no código.

Aplica-se a

Ver também