RenderOptions.SetCachingHint(DependencyObject, CachingHint) メソッド

定義

指定した依存関係オブジェクトの CachingHint 添付プロパティの値を設定します。

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)

パラメーター

target
DependencyObject

CachingHint プロパティの値を設定する対象の依存関係オブジェクト。

cachingHint
CachingHint

プロパティの新しい設定値。

例外

指定された targetnull です。

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 の既定の動作では、コンテンツが変更されていない場合でも、フレームごとにブラシのすべてのコンテンツを再レンダリングします。 たとえば、これは、静的 DrawingBrush な場合や VisualBrush 、回転する 3D オブジェクトのサーフェスにマップされている場合に発生します。 静的コンテンツを再レンダリングすると、パフォーマンスに悪影響を及ぼす可能性があります。

ブラシCacheの添付プロパティをCachingHint設定すると、キャッシュされたバージョンのタイル 化されたブラシ オブジェクトを使用してパフォーマンスを向上させることができます。

CacheInvalidationThresholdMinimumプロパティ値とCacheInvalidationThresholdMaximumプロパティ値は、スケールが変化したためにオブジェクトをTileBrushいつ再生成するかを決定する相対サイズの値です。 たとえば、プロパティが CacheInvalidationThresholdMaximum 2.0 に設定されている場合、キャッシュのサイズが現在の TileBrush キャッシュのサイズの 2 倍を超える場合にのみ、キャッシュを再生成する必要があります。

コードで添付プロパティを設定するには、 CachingHint このメソッドを使用します。

適用対象

こちらもご覧ください