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) ,控制項必須依下列順序迴圈 ToggleState 執行: OnOff 和 (。

適用於

另請參閱