Compartilhar via


Change the startup page of a Silverlight project in Expression Blend 2

This page applies to Silverlight 1 projects only

A Microsoft Silverlight 1.0 application runs in a web browser by opening an HTML page (or other web page) that instantiates any supporting Silverlight objects and then displays your starting XAML file.

For example, in a Silverlight 1.0 project that is created in Microsoft Expression Blend 2, the Default.html file is the startup web page. The Default.html file references the following JavaScript files that support your Silverlight 1.0 application:

<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript" src="Page.xaml.js"></script>

The Default.html file also specifies your starting XAML file, Page.xaml, with the following lines of code:

Silverlight.createObjectEx({
    source: "Page.xaml",
    //other lines of code
});

The result of the previous code snippets is that when you browse to the Default.html file in your web browser, the resulting Silverlight 1.0 application will display the Page.xaml file first.

Note

Silverlight 1.0 applications that are created in other programs such as Microsoft Expression Encoder 2 or Microsoft Visual Studio 2008 have a different file structure, so you might have to locate the files that contain the preceding lines of code. For example, in an Expression Encoder 2 project that uses a Silverlight 1.0 template to produce a video player, the Default.html file is still the startup web page. However, the Default.html file does not specify the starting XAML file. The starting XAML file, Player.xaml, is specified in the StartPlayer.js file.

Use the following procedures to change the starting XAML file of your Silverlight 1.0 application, or the starting web page that calls your Silverlight 1.0 application.

Changing the starting XAML file

Changing the starting XAML file of your Silverlight 1.0 application differs from changing the starting XAML file of a Windows Presentation Foundation (WPF) application. The starting XAML file is called from a web page, such as the Default_html.js file in a Silverlight 1.0 project that is created in Expression Blend 2.

To change the starting XAML page of a Silverlight 1.0 project

  1. In Expression Blend 2, open the file that uses lines of code (similar to the following) to specify the starting XAML file of your Silverlight 1.0 application:

    Silverlight.createObjectEx({
        source: "Page.xaml",
        //other lines of code
    });
    

    For example, in a Silverlight 1.0 application that was created in Expression Blend 2, this file will be the Default.html file.

    Note

    If you do not have a text editor associated with the .html file name extension, you might have to modify the file by a) right-clicking the file name in the Project panel of Expression Blend and then clicking Edit in Visual Studio, or b) right-clicking the file name in Windows Explorer, pointing to Open With, and then selecting the text editor of your choice from the drop-down list. If no text editor appears in the drop-down list (such as Notepad), click Choose Default Program, and then browse for a text editor.

  2. Change the existing file name (for example, Page.xaml) to the name of the new starting XAML file.

  3. Save and close the file.

  4. Test your Silverlight 1.0 application (F5) to make sure that the modification works. For more information, see Test a Silverlight project from Expression Blend.

Cc295316.7e183f1f-37d8-4dcb-980c-19a5d61ca087(en-us,Expression.10).gifBack to top

Changing the startup web page

The startup web page is the page that is opened in your web browser when you test your Silverlight 1.0 application by pressing F5 in Expression Blend 2. The startup web page is identified by a check mark next to Startup when you right-click the file name in the Project panel in Expression Blend 2.

Note

Changing the startup web page in Expression Blend 2 does not change the startup web page in other programs such as Microsoft Visual Studio.

To change the startup web page of a Silverlight 1.0 project

  1. In Expression Blend 2, right-click the file name of the new startup web page in the Project panel, and then click Startup.

  2. Test your Silverlight 1.0 application (F5) to make sure that the modification works. For more information, see Test a Silverlight project from Expression Blend.

    Note

    Your Silverlight 1.0 application will not work if your startup web page does not include references to supporting Silverlight 1.0 files. For example, in a Silverlight 1.0 project that is created in Expression Blend 2, the supporting files are the Silverlight.js and the Page.xaml.js files. For more information about Silverlight 1.0 objects, see Silverlight Object Models on MSDN.

Cc295316.7e183f1f-37d8-4dcb-980c-19a5d61ca087(en-us,Expression.10).gifBack to top

See also

Concepts

Set a startup document for your project

Managing your projects and files

Test a Silverlight project from Expression Blend

Other resources

Microsoft Silverlight site

Silverlight 1.0 - Development with JavaScript