Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DynamicApplication Class

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Represents an application object for dynamic language applications, and provides the entry point for the application.

Namespace:  Microsoft.Scripting.Silverlight
Assembly:  Microsoft.Scripting.Silverlight (in Microsoft.Scripting.Silverlight.dll)

public class DynamicApplication extends Application

The DynamicApplication class contains the entry point for dynamic language applications. It starts the dynamic language runtime, and provides the application with access to the root interface object.

To obtain the DynamicApplication object for your application, use the DynamicApplication.Current property.

Note:

You can also use the static Application.Current property, but only if your code is executing on the user interface thread.

To load the root interface object for your application, use the LoadRootVisual method.

The following example shows simple startup code for IronPython, IronRuby, and Managed JScript. In each case, the example defines an App class with a start method, creates an instance of the class, and calls the start method.

The example uses an app.xaml file, which is the same for all languages. The file is listed following the code.

On initialization, the example uses the Application.Current property to get the DynamicApplication object, and then uses the LoadRootVisual method to load a UserControl from the app.xaml file, which is located in the same folder as the entry point code. In the start method, the example sets the text of a TextBlock control named Message.

For information on running dynamic language code using Chiron.exe, see Dynamic Languages in Silverlight 2.

# ---- IronPython ----
from System.Windows import Application
from System.Windows.Controls import UserControl

class App:
    def __init__(self):
        self.scene = Application.Current.LoadRootVisual(UserControl(), "app.xaml")

    def start(self):
        # TODO: Replace this with your application start logic.
        self.scene.Message.Text = "Welcome to Silverlight and IronPython."

App().start()


# ---- IronRuby ----
include System::Windows
include System::Windows::Controls

class App

  def initialize
    @scene = Application.Current.LoadRootVisual(UserControl.new(), "app.xaml")
  end

  def start
    # TODO: Replace this with your application start logic.
    @scene.find_name('Message').text = "Welcome to Silverlight and IronRuby."
  end
end

App.new.start


// ---- Managed JScript ----
Import("System.Windows.Application")
Import("System.Windows.Controls.UserControl")

function App() {
    this.scene = Application.Current.LoadRootVisual(new UserControl(), "app.xaml")
}

App.prototype.start = function() {
    // TODO: Put application logic here.
    this.scene.Message.Text = "Welcome to Silverlight and Managed JScript."
}

app = new App
app.start()

The app.xaml file contains the following XAML:

<UserControl
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="System.Windows.Controls.UserControl"
  x:Name="Page" 
  >
  
  <TextBlock 
    x:Name="Message" TextWrapping="Wrap" Foreground="Black" >
  </TextBlock>
</UserControl>

System.Object
  System.Windows.Application
    Microsoft.Scripting.Silverlight.DynamicApplication

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft