Export (0) Print
Expand All

Working with XAML

Extensible Application Markup Language, or XAML (pronounced "zammel"), is an XML-based markup language developed by Microsoft. XAML is the markup behind the visual presentation of an app that you develop in Microsoft Visual Studio or Blend for Visual Studio You can edit XAML code in Blend either by hand directly in the code editor or visually by modifying properties in Design view.

For more information about the new XAML editing functionality in Blend for Visual Studio, see What’s new in Visual Studio 2013 Preview for authoring Windows Store XAML apps.

XAML is the part of the Microsoft .NET Framework that deals with the visual presentation of Windows-based apps and web browser–based client apps. You can create your UI entirely in XAML by defining elements such as controls, text, images, shapes, animation, and more. However, because XAML is declarative, XAML requires the addition of code if you want to add run-time logic to your app. Without the run-time logic, your app cannot perform and respond to user interaction.

The code for a XAML-based app is stored in a separate file from the XAML document. This separation of UI design (the presentation) from the underlying code not only enables developers and designers to work more closely together on the same project, but also more closely adheres to the best practice of separating the view of your app from the code, sometimes referred to as the model in the architecture pattern known as Model View ViewModel (MVVM).

Visual Studio is an ideal tool for developing the run-time logic for your app. Blend is an ideal tool for designing the visual presentation of your app. You can easily switch back and forth between Blend and Visual Studio while you're working on a project. To switch from Visual Studio to Blend, right-click the project in Solution Explorer, and then click Open in Blend. To switch from Blend to Visual Studio, right-click the project in the Projects panel, and then click Edit in Visual Studio.

Tip Tip

You can have the same project file open in both Blend and in Visual Studio at the same time, on the same computer. When you save a change to a file in one tool and then switch to the other, you'll be asked if you want to reload the file in order to view the most up-to-date version of the project.

For information about how use Blend with Visual Studio to design the presentation layer of your app, see Working with objects and properties.

The XAML for any given document in Blend is stored in a .xaml file. The underlying code for your XAML document is stored in a file of the same name with the additional extension of .cs, cpp, or .vb.

When you build your project, the parser reads the .xaml files for that project and reports any resulting errors. Likewise, when you open an existing project in Blend, the XAML parser reads the .xaml files that are included in your project folder and attempts to parse the elements and display the documents on the artboard in Design view. In both cases, if the parser encounters errors, the artboard is disabled, and Blend displays an error message with a link to open Code view so that you can resolve the errors. The parsing errors are also reported on the Errors tab in the Results panel.

For more information, see the following topics:

For information about the syntax of individual controls, see Control Library or search for XAML elements in the Class Library reference, both on MSDN.

Show:
© 2014 Microsoft