Share via


SilverlightHost.IsVersionSupported Method

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

Returns a value that indicates whether the installed Silverlight plug-in supports the specified version.

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

Syntax

'Declaration
Public Function IsVersionSupported ( _
    versionStr As String _
) As Boolean
public bool IsVersionSupported(
    string versionStr
)

Parameters

  • versionStr
    Type: System.String
    The version to check, in the form of major.minor.build.revision See Remarks for more information about the string form.

Return Value

Type: System.Boolean
true if the version can be supported by the installation; otherwise, false.

Remarks

The version string contains one through four integer values that are separated by dots, for example, "2.0.30908.0". The sequence of integers represents the major, minor, build, and revision numbers. For more information about versioning, see Silverlight Plug-in Versioning.

This method parallels the JavaScript function isInstalled, which is defined in the Silverlight.js helper file. You can use both methods to implement a plug-in upgrade experience. However, the JavaScript function enables you to do this before the installed plug-in version is loaded. For more information, see Silverlight.js Reference.

Examples

The following code example demonstrates how to use this method.

' 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.