UIElement.CacheMode Property
Gets or sets a value that indicates that rendered content should be cached when possible.
Namespace: System.Windows
Assembly: System.Windows (in System.Windows.dll)
<uiElement> <uiElement.CacheMode> singleBitmapCache </uiElement.CacheMode> </uiElement>
XAML Values
Property Value
Type: System.Windows.Media.CacheModeA value that indicates that rendered content should be cached when possible. If you specify a value of CacheMode, rendering operations from RenderTransform and Opacity execute on the graphics processing unit (GPU), if available. The default is Nothing, which does not enable a cached composition mode.
Dependency property identifier field: CacheModeProperty
In order to enable caching, you must enable composition caching at the plug-in level by setting the value of an EnableGPUAcceleration param element to true as part of the object tag that declares the Silverlight plug-in.
To use GPU hardware acceleration in Silverlight effectively, you should understand how Silverlight uses hardware acceleration and cached composition in its architecture, and which Silverlight objects and rendering scenarios can benefit under hardware acceleration. For more information, see Silverlight Hardware Acceleration.
You can profile hardware acceleration optimizations in the development phase of your application; see EnableCacheVisualization (Silverlight Plug-in Object).
The XAML usage shown is the only practical available usage in Silverlight core libraries. In theory, other CacheMode classes could be written to fill the CacheMode value, but these would be custom classes. See BitmapCache for the attributes you might set on the BitmapCache object element value.
Note: |
|---|
Out-of-browser applications do not have editable hosting HTML. To enable GPU acceleration for an out-of-browser application, set the attribute EnableGPUAcceleration to true on the OutOfBrowserSettings element that you declare in your Deployment XAML file. |
Version Notes
Silverlight for Windows Phone
Before you can use the CacheMode property, you need to enable GPU acceleration at the plug-in level (in the HTML) by setting the EnableGPUAcceleration parameter to true.
<param name="EnableGPUAcceleration" value="true" />
The following XAML uses a BitmapCache to set CacheMode for a MediaElement.
<MediaElement> <MediaElement.CacheMode> <BitmapCache RenderAtScale="4"/> </ MediaElement.CacheMode> </MediaElement>
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Note: