VisualState.Name 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 VisualState 的名称。
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
属性值
VisualState 的名称。
示例
以下示例在调用项中创建一个VisualStateGroupButton,CommonStates
并为状态、Pressed``Normal
和添加VisualStateMouseOver
对象。ControlTemplate The Button also defines a state called Disabled
that is in the CommonStates
VisualStateGroup, but the example omits it for brevity. 有关整个示例,请参阅 通过创建 ControlTemplate 自定义现有控件的外观。
<!--Define the states and transitions for the common states.
The states in the VisualStateGroup are mutually exclusive to
each other.-->
<VisualStateGroup x:Name="CommonStates">
<!--The Normal state is the state the button is in
when it is not in another state from this VisualStateGroup.-->
<VisualState x:Name="Normal" />
<!--Change the SolidColorBrush, BorderBrush, to red when the
mouse is over the button.-->
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BorderBrush"
Storyboard.TargetProperty="Color"
To="Red" />
</Storyboard>
</VisualState>
<!--Change the SolidColorBrush, BorderBrush, to Transparent when the
button is pressed.-->
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BorderBrush"
Storyboard.TargetProperty="Color"
To="Transparent"/>
</Storyboard>
</VisualState>
<!--The Disabled state is omitted for brevity.-->
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
注解
可以通过将元素传递给 Name VisualState VisualStateManager元素来指定应输入的视觉状态。
When a Control uses the VisualStateManager in a ControlTemplate, the control author should specify which VisualState objects the control expects to find in its ControlTemplate by putting the TemplateVisualStateAttribute on its class signature. ControlTemplate 作者定义新 VisualState 对象,并将 Name 属性设置为属性指定的 TemplateVisualStateAttribute.Name 值。
若要查找 WPF 中包含的控件的视觉状态的名称,请参阅 控件样式和模板。 有关如何为现有控件创建 ControlTemplate 和 VisualState 对象的信息,请参阅 通过创建 ControlTemplate 自定义现有控件的外观。