IToggleProvider.ToggleState 属性

定义

获取控件的切换状态。

public:
 property System::Windows::Automation::ToggleState ToggleState { System::Windows::Automation::ToggleState get(); };
public System.Windows.Automation.ToggleState ToggleState { get; }
member this.ToggleState : System.Windows.Automation.ToggleState
Public ReadOnly Property ToggleState As ToggleState

属性值

ToggleState

控件的 ToggleState

示例

以下示例演示了可切换的控件的此方法的实现。 返回的 ToggleState 基于控件的颜色;这类似于 IsChecked CheckBox 控件的属性。

/// <summary>
/// Retrieves the toggle state of the control.
/// </summary>
/// <remarks>
/// For this custom control the toggle state is reflected by the color 
/// of the control. This is analogous to the CheckBox IsChecked property.
/// Green   - ToggleState.On
/// Red     - ToggleState.Off
/// Yellow  - ToggleState.Indeterminate
/// </remarks>
ToggleState IToggleProvider.ToggleState
{
    get
    {
        return customControl.toggleStateColor[customControl.controlColor]; ;
    }
}
''' <summary>
''' Retrieves the toggle state of the control.
''' </summary>
''' <remarks>
''' For this custom control the toggle state is reflected by the color 
''' of the control. This is analogous to the CheckBox IsChecked property.
''' Green   - ToggleState.On
''' Red     - ToggleState.Off
''' Yellow  - ToggleState.Indeterminate
''' </remarks>
Private ReadOnly Property IToggleProvider_ToggleState() As ToggleState Implements IToggleProvider.ToggleState
    Get
        Return customControl.toggleStateColor(customControl.controlColor)

    End Get
End Property

注解

如果支持Indeterminate) ,控件必须按以下顺序循环访问它ToggleStateOnOff (。

适用于

另请参阅