Dela via


Edit a code-behind file

To edit a code-behind file in a Microsoft Expression Blend project, you can double-click the file name under Files in the Project panel.

If the file is a Microsoft Silverlight 1.0 code-behind file written in JavaScript, the file will open in Expression Blend 2, in a JavaScript editing window.

If the file is a Windows Presentation Foundation or Silverlight 2 project code-behind file written in C# or Visual Basic .NET, and you have Microsoft Visual Studio installed, the code-behind file will open automatically in Visual Studio. However, if you do not have Visual Studio installed, Expression Blend will not know how to open the file, so you must create an association between the file extension of the code-behind file (.cs or .vb) and an editing program, such as Notepad.

Tip

For more information about working with code in Expression Blend applications, see Code editing and Visual Studio 2008 interoperability, Debug Expression Blend applications in Visual Studio 2008, and Event handling overview.

To associate an editor with a .cs or .vb code file

  1. Open Windows Explorer or My Computer.

  2. On the Tools menu, click Folder Options.

  3. In the Folder Options window, click the File Types tab.

  4. Under Registered file types, look for the file extension of your code-behind file in the Extensions column.

    • If you see your file extension, examine the Details to see which program is associated with the extension. If you want to use the listed program to open your code-behind files, you do not need to do anything else, so click OK. If you want to use a different program, click Change.

    • If you do not see your file extension, click the New button to open the Create New Extension dialog box, enter the extension (CS or VB) in the File Extension text box, and then click OK. Back in the Folder Options window, with your new extension selected, click Change.

  5. In the Open With dialog box, select the program that you want to use to open code-behind files (for example, Notepad), and then click OK.

To open a .cs or .vb code-behind file

  1. In Expression Blend, under Files in the Project panel, expand the node for your document (for example, Window1.xaml) to see the code-behind file.

  2. Double-click the code-behind file.

    Tip

    When you open a single code-behind file in Microsoft Visual Studio 2008 instead of opening the entire project and then the file, you cannot use the auto-complete, Build, and Debug features of Visual Studio.

To open a .js file

  • In Expression Blend, under Files in the Project panel, double-click JavaScript code file (for example, the Page.xaml.js code-behind file).

    The code file will open in Expression Blend 2, in a JavaScript editing window.

    Warning

    It is recommended that you do not modify the Silverlight.js helper file.

Open an Expression Blend project in Visual Studio 2008

See also

Concepts

XAML editing

Debug Expression Blend applications

Debug Expression Blend applications in Visual Studio 2008

Deploy and publish Expression Blend applications