次の方法で共有


IXRVisualState (Windows Embedded CE 6.0)

1/6/2010

This class represents the visual appearance of the control when it is in a specific state.

Syntax

class IXRVisualState : public IXRDependencyObject

Methods

Method Description

IXRVisualState::GetStoryboard

Retrieves an IXRStoryboard that defines the appearance of the control when it is in the state that is represented by this IXRVisualState.

IXRVisualState::SetStoryboard

Sets an IXRStoryboard that defines the appearance of the control when it is in the state that is represented by this IXRVisualState.

Remarks

An IXRVisualState object specifies how the control looks when it is in a certain state. For example, when a button is pressed, its border might be a different color than usual. The IXRVisualState class provides methods that change the appearance of the control. When the control enters the state that is specified by its name, the storyboard animation begins. When the control exits the state, the storyboard animation ends. The state name can be retrieved or set by using the inherited methods IXRDependencyObject::GetName and IXRDependencyObject::SetName. The state name is also used by the IXRControl::GoToVisualState method.

After you create a new IXRVisualState object and provide a state name, you can customize the visual appearance of that state by calling IXRVisualState::SetStoryboard and providing a new IXRStoryboard object.

A collection of IXRVisualState objects for a control are stored in an IXRVisualStateCollection. This collection belongs to an IXRVisualStateGroup object, and can be accessed by using IXRVisualStateGroup::GetStates.

A collection of visual-state groups, represented by IXRVisualStateGroupCollection, can be accessed through an attached property on an IXRFrameworkElement child element of an IXRUserControl. The attached property is called VisualStateManager.VisualStateGroups.

To use this object in C++, the control must inherit from IXRUserControl, which inherits from IXRControl. Then, you can do the following:

  1. Create one or more new IXRVisualState objects and a new IXRVisualStateCollection.
  2. Add the IXRVisualState objects to the IXRVisualStateCollection by calling its inherited method IXRCollection<In_T, Out_T>::Add.
  3. Create a new IXRVisualStateGroup object, and add the new collection to it by calling IXRVisualStateGroup::SetStates.
  4. Create a new IXRVisualStateGroupCollection object, and add the IXRVisualStateGroup object to it by calling its inherited method IXRCollection<In_T, Out_T>::Add.
  5. Next, create a new IXRFrameworkElement root element to represent a new child element for the control.
  6. On the IXRFrameworkElement object, call IXRDependencyObject::SetAttachedProperty(const WCHAR*, IXRDependencyObject*) and set the IXRVisualStateGroupCollection object as the VisualStateManager.VisualStateGroups attached-property value.
  7. After the visual states are added to the IXRFrameworkElement root element, add the root element to the user control by calling IXRUserControl::SetContent.

You can also define a visual state in Microsoft Silverlight 2 XAML, in the source XAML that is parsed by your application. For information about the differences between XAML in Silverlight for Windows Embedded and Silverlight 2, see Differences Between Silverlight for the Web and Silverlight for Windows Embedded. For more information about how to define this element in the source XAML for your application, see this Microsoft Web site.

Note

The contents of a ControlTemplate defined in Microsoft Silverlight 2 XAML cannot be accessed from C++. Therefore, visual states and visual-state groups that were defined in a ControlTemplate in the source XAML for your application cannot be accessed in Silverlight object tree.

Inheritance Hierarchy

IXRDependencyObject

    IXRVisualState

.NET Framework Equivalent

System.Windows.VisualState

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

Classes for Visual Appearance and Behavior
IXRControl::GoToVisualState

Other Resources