次の方法で共有


Build an Interactive XAML Application (Compact 2013)

3/26/2014

You can enable your XAML for Windows Embedded application to respond to user input and system events by using the following methods:

  • Event Handling. Various events occur during the lifetime of an application. For example, most UI objects raise an event in response to the user clicking the object. This is called a MouseLeftButtonDown event. You can create a method to handle this event, and then attach it to an object by using the AddClickEventHandler method. For events that are not specific to XAML for Windows Embedded (such as the application’s Loaded event), you can use the Windows event processing model.
  • Behaviors, Actions, and Triggers. Behaviors encapsulate interactions as reusable components that are applied to a UI element in an application. A behavior consists of an action and a trigger. When the trigger occurs, the corresponding action occurs. For more information, see Behaviors, Actions, and Triggers.
  • Visual States. A state defines the visual appearance of a control in a particular state, such as the Pressed state of a Button object, or the MouseOver state of a RadioButton control. Common controls come with pre-defined states that you can modify in a copy of their template. If you are working with UserControls, you can create your own custom states, and write code that will change states in response to events or other user interactions.

If you use any of these methods in an Blend for Visual Studio project, the following occurs when you convert the project into a XAML for Windows Embedded project in Visual Studio (included here because it may affect your decision about which method to use):

  • Event Handling. If you create and hook up an event handler method in Expression Blend and then convert or update the project by using Windows Embedded XAML Tools , C++ event handler method stubs will be generated and hooked up automatically. In the converted project, you will have to add code to the stub method for an action to occur in response to the event.
  • Behaviors. If you use one of the supported behaviors in Expression Blend and then convert or update the project by using Windows Embedded XAML Tools, C++ code will be generated to call the corresponding XAML for Windows Embedded behavior, and the behavior should work without any extra coding on your part. If you use one of the unsupported behaviors in an Expression Blend project, or if you use a custom behavior, the behavior will not be converted by Windows Embedded XAML Tools. This is because custom behaviors in Expression Blend are written in managed code (C#.NET or Visual Basic .NET). To create a matching custom behavior in XAML for Windows Embedded, you will have to implement a C++ version of your behavior using the XRBehavior class and register it, before you can use the custom behavior on any of your UI controls.
  • Visual States. If you modify the visual states in a customized control template in Expression Blend, and then convert or update the project by using Windows Embedded XAML Tools, your state customizations will persist and will work without any extra coding on your part. If you create a custom user control and add states, you will have to add code to your converted project to change states in response to user actions, typically in event handler methods.

In This Section

See Also

Concepts

XAML for Windows Embedded Application Development