Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
Silverlight 3
Application Class
 RootVisual Property
Collapse All/Expand All Collapse All
.NET Framework Class Library for Silverlight
Application..::.RootVisual Property

Gets or sets the main application UI.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
Public Property RootVisual As UIElement
    Get
    Set
Visual Basic (Usage)
Dim instance As Application
Dim value As UIElement

value = instance.RootVisual

instance.RootVisual = value
C#
public UIElement RootVisual { get; set; }

Property Value

Type: System.Windows..::.UIElement
A UIElement that is the main application UI.
ExceptionCondition
InvalidOperationException

When setting this property, the specified value is not an instance of a class that derives from UIElement.

You can set the value of the RootVisual property only one time from code, although you get its value any number of times.

The following code example demonstrates how an application can use a Startup event handler to set the RootVisual property.

Visual Basic
Partial Public Class App
    Inherits Application

    public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Application_Startup(ByVal o As Object, _
        ByVal e As StartupEventArgs) Handles Me.Startup

        Me.RootVisual = New Page()

    End Sub


End Class
C#
using System.Windows; // Application, StartupEventArgs

namespace SilverlightApplication
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Specify the main application UI
            this.RootVisual = new Page();
        }
    }
}

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker