CachingHint 列舉

定義

指定是否快取並排顯示筆刷物件。

public enum class CachingHint
public enum CachingHint
type CachingHint = 
Public Enum CachingHint
繼承
CachingHint

欄位

Cache 1

使用RenderOptions 設定所指定的快取提示,快取螢幕外緩衝區的並排顯示筆刷物件。

Unspecified 0

未指定任何的快取提示。

範例

下列範例示範如何使用 的 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)

備註

根據預設,WPF 不會快取 和 VisualBrush 物件的轉譯內容 DrawingBrush 。 在靜態案例中,內容和場景中筆刷的使用都未變更,而不是快取可提供優點,因為它可節省視訊記憶體。 以非靜態方式使用具有靜態內容的筆刷時,WPF 的預設行為是重新轉譯每個畫面的筆刷整個內容,即使內容未變更也一樣。 例如,當靜態 DrawingBrushVisualBrush 對應至旋轉 3D 物件的表面時,就會發生這種情況。 重新轉譯靜態內容可能會對效能造成負面影響。

藉由將 CachingHint 筆刷上的附加屬性設定為快取,您可以使用已快取版本的並排筆刷物件來提升效能。

CacheInvalidationThresholdMinimumCacheInvalidationThresholdMaximum 屬性值是相對大小值,可決定 TileBrush 何時應該因為縮放比例變更而重新產生物件。 例如,藉由將 CacheInvalidationThresholdMaximum 屬性設定為 2.0, TileBrush 只有在其大小超過目前快取大小的兩倍時,才需要重新產生快取的快取。

適用於

另請參閱