Content Index Search

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 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 2005 interoperability, Debugging Expression Blend applications in Visual Studio 2005, and Event Handling.

To associate an editor with a 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 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 Visual Studio 2005 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 an Expression Blend project in Visual Studio 2005

This procedure requires that you have Visual Studio 2005 installed (or another program that can be used for the development of applications that are based on the Microsoft .NET Framework), and an association between the project file extension (.csproj or .vbproj) and the development program. This association is created automatically when you install the development program.

  1. In Expression Blend, make sure that your project is saved, because you cannot open a code-behind file or a project without first saving the project. To save your project, click Save All on the File menu, enter a name and location in the Save Project dialog box, and then click OK.
  2. Under Files in the Project panel, right-click your project name, and then click Edit Externally.