Create a Silverlight 1.0 site that has interactivity
Interactivity in Microsoft Silverlight 1.0 applications is created by using event handlers in the JavaScript code-behind files of the XAML documents where you design your user interface. The following procedure shows you how to make your application play an animation storyboard in response to a mouse click.
To create a Silverlight 1 site that has interactivity
In Microsoft Expression Blend, click New Project on the File menu.
The New Project dialog box appears.
Under Select a project type, click Silverlight 1.0 Site. The other fields display default values for the project name and location. You can leave those fields as they are and click OK.
A new Silverlight project is created and the startup page, Page.xaml, opens for editing.
From the Toolbox, select the Pen tool. Draw a curving shape by clicking to create points and dragging to create curves. Click on the first point to close the shape.
For a list of ways to modify a path with your mouse, see Pen and direct selection usage.
Right-click your new path object under Objects and Timeline, click Rename, and then enter the name MyPath.
If an object is going to be referenced from a code-behind file, it needs a name. This object will need to be referenced from code in order to hook up a Click event handler.
Under Objects and Timeline, click the New button. The Create Storyboard dialog box appears. Leave the Name field as Storyboard1 and the Create as a Resource checkbox selected, and then click OK.
A new storyboard is created and timeline recording is turned on.
With the timeline playhead at the 0-second mark, click the Record Keyframe button to record the current position of the MyPath object.
Move the timeline playhead to the 1-second mark, and then use the Selection tool to move the MyPath object. A keyframe is set at the 1-second mark to record the new position of the MyPath object.
In the Project panel, double-click the Page.xaml.js file to open it for editing.
Uncomment the following line of code by removing the // characters:
// this.control.content.findName("Storyboard1").Begin();
Expression Blend 2 generates initial JavaScript code to show you how to hook up an event handler to a mouse button click on the root element. The event handler calls the Begin method for Storyboard1, which is why you did not change the Name field when you created the storyboard. For more information about Silverlight 1.0 scripting, see Silverlight scripting and mouse events.
Test your Silverlight 1.0 site by pressing F5 and clicking in the browser window to trigger the animation storyboard.
See also
Concepts
Create a button that controls a storyboard in a Silverlight application
Create, modify, or delete a storyboard
Modify a storyboard to repeat or reverse at the end of its cycle