Getting Started with XAML for Windows Embedded (Compact 2013)
This tutorial describes how to create and modify a XAML for Windows Embedded application by using the following tasks:
- Create a XAML for Windows Embedded application template from a sample Blend for Visual Studio project
- Add C++ code to the template to create a functioning application
- Add event handlers to the application using the Windows Embedded XAML Tools event handler viewer
- Update the application using an updated version of the Expression Blend project
Windows Embedded XAML Tools Workflow
Windows Embedded XAML Tools is a plug-in for Microsoft Visual Studio 2013 and Microsoft Visual Studio 2015 that helps you convert Expression Blend XAML for Windows Embedded projects into native (C++) Windows Embedded Compact applications. These tools are useful if you use Expression Blend to create the XAML markup that defines the user interface (UI) of your application.
The XAML for Windows Embedded Platform Builder Subproject Application Wizard walks you through the steps for creating a template Platform Builder subproject from the XAML (eXtensible Application Markup Language) and resource files of an Expression Blend project. Starting with this generated template, you can add functionality to create a native Windows Embedded Compact application that has a XAML for Windows Embedded UI designed in Expression Blend.
When you are ready to create event handlers for your XAML for Windows Embedded UI objects, the Windows Embedded Events view allows you to select objects and events (such as KeyDown and MouseLeftButtonDown) to associate with those objects, automatically generating C++ stub event handlers when you add new events.
You can later modify your XAML for Windows Embedded project in Expression Blend and then merge these changes into your Platform Builder subproject using the Windows Embedded XAML Tools update tool. Windows Embedded XAML Tools automates the process of using Expression Blend files to create XAML for Windows Embedded-based Windows Embedded Compact applications. This automation eliminates difficult and time-consuming tasks, diminishes the likelihood of introducing human error, and frees you to focus on the business logic of your application. The ability to merge UI updates during and after application development makes it possible for the designer and the developer to work on an application in parallel, so the application can be finished more quickly.
How Windows Embedded XAML Tools Work
When a designer creates graphics, animations, and UI elements in Expression Blend, the resulting Expression Blend project contains XAML files that describe the visual components and UI characteristics of an application. However, these XAML files may include elements that XAML for Windows Embedded does not support. For each of these XAML files, Expression Blend generates a .NET code-behind file that may contain C# application code. However, because Windows Embedded Compact applications must be written in C++ to use the Windows Embedded Compact native XAML for Windows Embedded runtime, you cannot use these Expression Blend-generated code-behind files as an application template. To use an Expression Blend project as the basis for a Windows Embedded Compact application, you need some way to convert Expression Blend project files to the tools and native runtime of Windows Embedded Compact.
Windows Embedded XAML Tools bridges this gap between the Expression Blend project and the Windows Embedded Compact development environment by providing features that do the following:
- Verify incoming XAML files for use with XAML for Windows Embedded, locating and reporting any unsupported elements.
- Automatically generate template application C++ code from XAML source files.
- Provide a way to easily select objects, hook up events, and add event handlers to your Expression Blend-derived application.
- Automatically identify changes in the Expression Blend project and propagate these changes to your application’s project resource files.
Without Windows Embedded XAML Tools, you would have to manually parse each incoming XAML file to identify and remove unsupported elements. For large Expression Blend projects, this porting task could be a tedious and error-prone process. Since the code-behind files that Expression Blend generates are not suitable for use with Windows Embedded Compact, you would have to manually write your own complex application code to manage the XAML for Windows Embedded runtime and attach event handlers to XAML objects. When the designer makes changes to the source Expression Blend project, you would have to manually find and merge these changes into your application project. Windows Embedded XAML Tools merges Expression Blend project updates with a mouse click, making all of these tasks unnecessary.
Although Windows Embedded XAML Tools provides many capabilities for accelerating your application development, it does have several limitations:
- It does not create XAML files.
- It does not generate managed source code. It only generates C++ code to use with Windows Embedded Compact.
- It does not generate C++ code for the following XAML elements or their child elements:
- It does not support custom controls; therefore, you must manually register any custom controls in your application.
- It does not handle manual modifications that you make to your XAML for Windows Embedded project outside of Expression Blend.
Windows Embedded XAML Tools is not a replacement for Expression Blend, Visual Studio, or Platform Builder; it complements these tools by providing an efficient way to use Expression Blend project files as the basis for Windows Embedded Compact applications. For this reason, Windows Embedded XAML Tools does not offer overlapping functionality that is already available in these other tools.
Typically, a designer creates a XAML for Windows Embedded-based UI project in Expression Blend and passes it to a developer. The developer, in turn, creates a Windows Embedded Compact application from the project. Using resources from the Expression Blend project, the developer writes and tests the code that implements the functionality of the application. To enable the designer and developer to work on the application in parallel, they create a Designer/Developer contract that defines the interface between the UI and the business logic of the application. If the designer and the developer properly follow this contract, they can assemble the XAML from the Expression Blend project and the C++ files from the developer at any time to view the current state of the application.
Windows Embedded XAML Tools works on the assumption that you and your designer are developing your application according to a Designer/Developer contract, and that there is a clearly defined interface between the UI and the application implementation. For more information about this development process and the Designer/Developer contract, see Designer and Developer Workflow in XAML for Windows Embedded.
Windows Embedded XAML Tools provides support for three common XAML for Windows Embedded development tasks:
- Generating an application template from an Expression Blend project
- Adding event handlers
- Updating your application with changes made to the Expression Blend project
Each of these tasks is described in this section, with tutorial examples that demonstrate how Windows Embedded XAML Tools can help you quickly create XAML for Windows Embedded-based applications for Windows Embedded Compact.