Page view counter
QuickStart Description
Animations Describes how to create basic animations by changing property values and by using key frames.
Audio and Video Describes how to integrate media into your applications.
Images Describes how to integrate images into your applications.
Deep Zoom Describes how to create a Deep Zoom image, load a Deep Zoom image, and add interactivity.
Control Templates Describes how to create a ControlTemplate to customize the appearance of a CheckBox control.
Data Binding to Controls Describes how to data bind to a control and customize the display.
HTML Bridge Describes how to access the HTML DOM from managed code, and to call managed code from JavaScript.
Isolated Storage Describes how to save and retrieve data as key-value pairs or files in isolated storage.
LINQ to XML Describes hows how to use LINQ to filter, group, sort, transform, and project an RSS feed.
Syndication Feeds Describes how to create a Silverlight client that can access and display a syndication service.
Web Services Provides an introduction to using Web services in Silverlight.
Dynamic Languages Demonstrates dynamic languages (Python and Ruby) by showing the DLR Console sample.
Home > Quickstarts > Dynamic Languages

Dynamic Languages

Dynamic languages provide an interactive approach to developing Silverlight-based applications. You can also use them to enable scripting for users of a Silverlight-based application. This QuickStart demonstrates the interactive nature of dynamic languages.

This QuickStart contains the following sections:

Note

The dynamic language runtime (DLR) enables dynamic languages to run on the common language runtime, and to use the .NET Framework class library for Silverlight. The DLR and three dynamic languages (IronPython, IronRuby, and Managed JScript) are currently under development. You can download them from the Silverlight Dynamic Languages SDK Web site on Codeplex.


DLR CONSOLE SAMPLE

The DLR Console is a sample application written in IronPython that enables you to write and execute Python or Ruby code. The following illustration shows the DLR Console.

Executing code in the DLR Console.

To try the DLR Console, click the following link and wait a few seconds for it to load. On the Console tab, click once to type code. At the py> prompt, type 1+1 and press ENTER to see the result. Next, type canvas.Background = wpf.RedBrush and press ENTER to change the background color of the right pane. For important information about using the DLR Console, see the Using the DLR Console section.

Run the DLR Console sample application in a new window


Note

You can download the most up-to-date source code for the DLR Console from the Silverlight Dynamic Languages SDK Web site.


USING THE DLR CONSOLE

The top left pane of the DLR Console provides tabs for entering code and XAML. The right side of the application is a resizable canvas for the code to manipulate. In the lower-left corner, the language block allows you to select a language. The Python language is selected by default. Sample code statements for the selected language are displayed in the block. You can enter these sample statements, using the Console tab, to create a text block that prints to the console when you click it.

There are three tabs for entering code and loading XAML:

  • Use the Console tab to execute code one statement at a time. Code is compiled and executed as soon as a statement is completed. When you write a multiline statement, such as a loop, an if statement, or a method definition, the console prompt changes from a caret to a vertical bar. While you are editing a multiline statement, use the arrow keys to move within the statement. When the statement is complete, press ENTER on an empty line to execute the statement and return to the caret prompt. At the caret prompt, you can use the UP ARROW key to retrieve previously entered statements.
  • Use the XAML tab to reset the canvas to its original appearance, or to edit the XAML to change its appearance. Press CTRL+ENTER to load the XAML that is currently shown on the tab.
  • Use the Code tab to edit and execute multiple statements. Press CTRL+ENTER to execute the code. The example code that is provided for each language adds a text block control that changes color when the mouse enters and leaves the text block.

When the Console tab executes a Python statement that returns a value, the result of the statement is displayed on the Console tab. Entering a variable name by itself displays the value of the variable. If the variable holds an object reference, a string representation of the object is displayed. The value of Ruby statements is always displayed.

Errors in the dynamic language code that you write are caught, and the error messages are displayed on the Console tab. Errors in the DLR Console itself are displayed at the bottom of the screen.

The tabs provide only basic editing capability:

  • Text can be selected by clicking and dragging. The keyboard cannot be used to select text. Selection by double-clicking is not supported.
  • The DELETE key is not supported; use the BACKSPACE key instead. Other keys that are not supported include the HOME and END keys.
  • There is no Undo functionality.
  • To type longer lines of code or to read error messages, use the divider to drag the canvas to the right.
  • The Console tab provides limited member name completion for the Python language when the type can be determined. (Variables in Python are not strongly typed.) Complete the name by pressing ENTER. The member name completion list does not include events.

See Also


Send Feedback
Microsoft Communities