Share via


Settings.EnableFrameRateCounter Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that indicates whether to display the current frame rate in the hosting browser's status bar. (Microsoft Internet Explorer only.)

Namespace:  System.Windows.Interop
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property EnableFrameRateCounter As Boolean
public bool EnableFrameRateCounter { get; set; }

Property Value

Type: System.Boolean
true if the frames-per-second (fps) of the current rendered Silverlight content will be displayed in the hosting browser's status bar; otherwise, false. The default is false.

Remarks

The EnableFrameRateCounter property is useful as a diagnostic while you are optimizing your application code by showing the frames-per-second (fps) of the current rendered Silverlight content. You can use the frame rate information to identify performance bottlenecks in your application.

You can set this property only at run time after the Silverlight plug-in has loaded. If you have a valid Settings object, then the Silverlight plug-in is guaranteed to be loaded. If you set this property to false after you set it to true, the counter will still appear, but will no longer be updated. You should set this property only while debugging, and remove it from production code.

The frame rate counter feature enabled by this property is supported on Microsoft Internet Explorer running on Windows XP SP2 or greater. Support on other browsers is not guaranteed.

The following illustration shows the frame rate displayed in the left side of the browser status bar. The frame rate value changes in response to Silverlight rendering requests:

Current framerate displayed in the browser status bar

Framerate counter

The format of the frame rate counter is as follows:

fps:currentFramerate/maxFramerate

currentFramerate is the optimal frame rate that would apply in absence of an upper frame rate limit, based on conditions of the plug-in's environment and reported by the plug-in. You can specify the maxFramerate value by setting the MaxFrameRate property when you embed the plug-in. The default value is 60.

The currentFramerate and maxFramerate values are interpreted to mean that whichever number is lower is the actual displayed frame rate. You can illustrate this relationship between currentFramerate and maxFramerate by setting a deliberately low frame rate, such as 2 per second, and observing the results.

If EnableGPUAcceleration is true AND EnableFrameRateCounter is true, an additional frame counter displays in the upper-left corner as an overlay within the Silverlight content area. The format of this frame rate counter is as follows:

frameRate videoMemoryUsed GPUEnabledSurfaces intermediateSurfaces

videoMemoryUsed is in KB. intermediateSurfaces refers to surfaces implicitly created to represent the software-rendered parts of the application on the GPU.

NoteNote:

Internet Explorer has a security setting that may prevent Silverlight (and other applications) from scripting to the status bar, and in this case you cannot see a framerate counter even when EnableFrameRateCounter is true. To rectify this situation, you must adjust the security settings of Internet Explorer for the pertinent zone. In the Internet Explorer menu, open Tools / Options / Security. Select Internet zone and Custom level. Enable Allow status bar updates via script. This consideration does not affect the additional framerate counter displayed if EnableGPUAcceleration is also true.

Examples

The following code example demonstrates how to use this property.

' The Host object, which represents the host Silverlight plug-in. 
Dim host As System.Windows.Interop.SilverlightHost = _
    Application.Current.Host

' The following code demonstrates how to use the Host object 
' to access other APIs in the System.Windows.Interop namespace. 

' The IsVersionSupported method. This method is useful when 
' you want to implement an upgrade experience in managed code. 
Dim isSupported As Boolean = host.IsVersionSupported("2.0.30908.0")

' Read-only properties of the Host object. 
Dim pluginBackground As System.Windows.Media.Color = host.Background
Dim loaded As Boolean = host.IsLoaded
Dim source As Uri = host.Source

' The Settings object, which represents Web browser settings. 
Dim settings As System.Windows.Interop.Settings = host.Settings

' Read/write properties of the Settings object. 
settings.EnableFrameRateCounter = True
settings.EnableRedrawRegions = True
settings.MaxFrameRate = 60

' Read-only properties of the Settings object. 
Dim windowless As Boolean = settings.Windowless
Dim htmlAccessEnabled As Boolean = settings.EnableHTMLAccess

' The Content object, which represents the plug-in display area. 
Dim content As System.Windows.Interop.Content = host.Content

' The read/write IsFullScreen property of the Content object. 
' See also the Content.FullScreenChanged event. 
Dim isFullScreen As Boolean = content.IsFullScreen

' Read-only properties of the Content object. These properties do 
' not contain meaningful values until after the Content.Resized 
' event occurs for the first time. 
Dim actualWidth As Double = content.ActualWidth
Dim actualHeight As Double = content.ActualHeight
// The Host object, which represents the host Silverlight plug-in.
System.Windows.Interop.SilverlightHost host = 
    Application.Current.Host;

// The following code demonstrates how to use the Host object
// to access other APIs in the System.Windows.Interop namespace.

// The IsVersionSupported method. This method is useful when
// you want to implement an upgrade experience in managed code.
bool isSupported = host.IsVersionSupported("2.0.30908.0");

// Read-only properties of the Host object.
System.Windows.Media.Color pluginBackground = host.Background;
bool loaded = host.IsLoaded;
Uri source = host.Source;

// The Settings object, which represents Web browser settings.
System.Windows.Interop.Settings settings = host.Settings;

// Read/write properties of the Settings object.
settings.EnableFrameRateCounter = true;
settings.EnableRedrawRegions = true;
settings.MaxFrameRate = 60;

// Read-only properties of the Settings object.
bool windowless = settings.Windowless;
bool htmlAccessEnabled = settings.EnableHTMLAccess;

// The Content object, which represents the plug-in display area.
System.Windows.Interop.Content content = host.Content;

// The read/write IsFullScreen property of the Content object.
// See also the Content.FullScreenChanged event.
bool isFullScreen = content.IsFullScreen;

// Read-only properties of the Content object. These properties do 
// not contain meaningful values until after the Content.Resized 
// event occurs for the first time. 
double actualWidth = content.ActualWidth;
double actualHeight = content.ActualHeight;

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.