Partilhar via


Working with solutions, projects, and files

When you work in Blend for Visual Studio 2012, all files are organized into a single project folder. This project system helps you manage all your working files and references in an efficient way, keeping them all in a local folder tree in the Projects panel.

The project system also makes it easy to test just a startup document or a whole project, and then build the project to a specific location when you are ready. The final product that you produce after you build a project depends on the project type:

  • A Windows Presentation Foundation (WPF) project builds a standard Microsoft Windows-based application (.exe).

  • A Microsoft Silverlight project builds a Silverlight application (.xap) and supporting files, which include an HTML test page that will load your application in a browser window.

Working with your project

Just as web documents are based on unique markup languages such as HTML, Blend documents are also based on a unique markup language, Extensible Application Markup Language (XAML). In Blend you can create new XAML documents, open, save, and delete existing documents, and even copy and rename documents, just as you can in many other applications. Blend also provides basic project recovery functionality and the ability to discard projects. You can accomplish most document-related tasks by using the commands that are located on the File, Edit, and Project menus. You can even right-click documents in the Projects panel and perform basic tasks quickly by using the shortcut menu. By default, Blend creates a .csproj or .vbproj file for your WPF and Silverlight projects, but also supports Microsoft Visual Studio solution files (.sln). For your Silverlight projects, Blend creates a website folder with no project or solution files.

For a roadmap of the Projects panel, see Projects panel.

The files in a WPF project

JJ170367.collapse_all(pt-br,VS.110).gifReferences folder

The References folder is used to store assemblies such as DLLs and executables. An assembly might be a user control .dll that you created in Blend, a .NET Framework custom control, or a compatible COM component.

Assembly references are listed in the Projects panel.

JJ170367.65aaebe1-ca4c-4805-a869-02d767be3c00(pt-br,VS.110).png

For more information, see Add or remove a reference.

JJ170367.collapse_all(pt-br,VS.110).gifResource dictionaries

Resource dictionaries contain reusable resources such as brush colors, styles and templates for controls, and other data types that you can assign to a property. Resource dictionaries are linked to your project by dictionary references in the App.xaml file or in another resource dictionary file.

A resource dictionary is just one type of XAML document that you can author in Blend. Additional XAML documents include windows, pages, and user controls.

For more information, see Create, export, or import a resource dictionary and Creating reusable resources.

JJ170367.collapse_all(pt-br,VS.110).gifLocal items

When you add a new or existing item to a project, the item appears in the Files list. Items include XAML documents, images, audio files, video files, 3D objects, 3D materials files, and more. You can create and add XAML documents to your project by using New Item on the File menu. Existing files are added to your project by using Add Existing Item on the Project menu.

For more information, see the following topics:

JJ170367.collapse_all(pt-br,VS.110).gifLinked-to items

You can link to existing items that don't live locally in your project folder but are stored elsewhere. Items include XAML documents, images, audio files, video files, 3D objects, 3D materials files, and others. A linked item is identified by an arrow superimposed over the file icon JJ170367.1cca22e6-da56-405c-a971-c52712d43334(pt-br,VS.110).png in the Files list.

For more information, see Add or link to an existing item.

JJ170367.collapse_all(pt-br,VS.110).gifCode files

The code-behind file for a XAML document shows as a child item under its respective XAML document. You can create a code file for a XAML document every time that you create a new XAML document by selecting the Include code file check box in the New Item dialog box. Code-behind files are typically used to run a procedure that involves more than setting a property or controlling an animation timeline (which can be done without code in your XAML document). For example, in a code-behind file, you can add other programming logic such as setting a property on another object, loading a new document, creating a new object, using a mathematical calculation to animate an object, and so on. For information about how to work with code-behind files, see Modify a code-behind file. For a comparison of what can be done with and without code, see Working with code. You might also add code files for custom classes to your project.

JJ170367.collapse_all(pt-br,VS.110).gifThe App.xaml file

An App.xaml file and corresponding code-behind file are created by default in an Blend project. The App.xaml file contains application-level resources that any document in your application can use. Application-level resources are listed in the Resources panel under the App.xaml node. You can add resources to the App.xaml file by selecting Application in the Create Resource window. For more information, see Creating reusable resources and Create a resource.

JJ170367.collapse_all(pt-br,VS.110).gifThe AssemblyInfo.cs file

By default, an AssemblyInfo.cs file is created in an Blend project. The AssemblyInfo.cs file contains settings for your project that are used when you compile your application. Do not modify the AssemblyInfo.cs file.

JJ170367.collapse_all(pt-br,VS.110).gifThe project and solution file

A project file (.vbproj or .csproj) and a solution file (.sln) file are created for WPF applications in Blend. These files are compatible with Microsoft Visual Studio 2010.

Observação de cuidadoCuidado

Managing your project files requires some diligence, because renaming and moving documents and items in your project folder can lead to broken links and references. For this version of Blend, practice keeping your renaming and moving tasks to a minimum and remember that if you do rename or move an item or reference, you'll have to manually update all references to those renamed or moved items and references to make sure that your project works as expected. Do not rename or delete the App.xaml files or the AssemblyInfo.cs file.

The files in a Silverlight project

Blend creates the same set of files as Microsoft Visual Studio 2010 when you create a project for a Silverlight application and select the Dynamically generate an HTML test page to host Silverlight within this project option in the Add Silverlight Application dialog box of Visual Studio 2010.

The following files are generated when you create a Silverlight project.

File

Description

ProjectName.sln

A Visual Studio solution file that specifies configuration settings for the solution, and references all the projects in the solution.

ProjectName.csproj

or

ProjectName.vbproj

A project file that specifies configuration settings for the project (including the starting web page), and references all the source files in the project.

App.xaml

A file where application-level resources are defined. For example, if you customize a button template and select to define it at the application level, any document in your project can use the template to style a button.

App.xaml.cs

or

App.xaml.vb

The code-behind file for the App.xaml file.

Page.xaml

A default XAML file in which to begin designing the user interface of your Silverlight application.

Page.xaml.cs

or

Page.xaml.vb

The code-behind file for the corresponding content file. User interaction and application behavior is often programmed in the code-behind file.

AppManifest.xml

Defines the assemblies that are included in the Silverlight application. For example, a Silverlight project created in Blend will build a Silverlight application in an assembly file (ProjectName.dll), so an AppManifest.xml will always list at least the assembly created by the project in which it resides.

AssemblyInfo.cs

or

AssemblyInfo.vb

Defines properties for the application, such as the version number, description, loaded assemblies, and so on.

DicaDica

The file that you will work with most often is Page.xaml, which is where you can design the user interface of your Silverlight application. Other files you might modify are the App.xaml file and any other content files (.xaml) that you add to your project.

When you build and test a Silverlight project, the following files are created in the \bin\debug folder, and Blend tries to open the starting web page.

File

Description

AppManifest.xaml

A Silverlight version of the AppManifest.xml file.

Default.html (or TestPage.html if the project was created with Visual Studio 2010)

A web page that loads the Silverlight application (contained in ProjectName.xap) into the browser.

ProjectName.dll

The compiled assembly of the application that you designed in the content files of your project.

ProjectName.pdb

Debug information for the application.

ProjectName.xap

A compressed archive that includes all the content and resources for the Silverlight application. Users download this file on their browsers and run it with the Silverlight plug-in.

JJ170367.collapse_all(pt-br,VS.110).gifReferences

When you create a new project, default references to Silverlight assemblies are added for you. It is in these referenced assemblies that the controls such as Button and TextBox are defined. You can add other Silverlight assembly references as you need them. You can also add references to .dll files that are compiled from other Silverlight projects.

For more information, see Import a custom control by adding a reference.

Testing and building your project

Blend provides basic testing functionality so that you can test your project before you build. When you test your project, the document that is identified as the Startup page is displayed first. The project will always open the Startup page first. The Blend build process uses the new Microsoft build platform, MSBuild. MSBuild defines both what you'll be building in addition to how you'll build it.

For more information about MSBuild, see the MSBuild Overview on MSDN. Signing and other release-related tasks such as debugging, securing, and deploying your project must be managed through Visual Studio or Visual Studio Express.

See the following topics for more information about these tasks: