TogglePattern.Toggle 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
AutomationElement의 상태를 설정/해제합니다.
public:
void Toggle();
public void Toggle ();
member this.Toggle : unit -> unit
Public Sub Toggle ()
예제
다음 예제에서는 TogglePattern 컨트롤 패턴에서 가져온는 AutomationElement 는 이후에 설정/해제 하는 데 사용 됩니다는 AutomationElement합니다.
///--------------------------------------------------------------------
/// <summary>
/// Obtains a TogglePattern control pattern from an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A TogglePattern object.
/// </returns>
///--------------------------------------------------------------------
private TogglePattern GetTogglePattern(AutomationElement targetControl)
{
TogglePattern togglePattern = null;
try
{
togglePattern =
targetControl.GetCurrentPattern(TogglePattern.Pattern)
as TogglePattern;
}
catch (InvalidOperationException)
{
// object doesn't support the TogglePattern control pattern
return null;
}
return togglePattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a TogglePattern control pattern from an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A TogglePattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetTogglePattern( _
ByVal targetControl As AutomationElement) As TogglePattern
Dim togglePattern As TogglePattern = Nothing
Try
togglePattern = DirectCast( _
targetControl.GetCurrentPattern(togglePattern.Pattern), _
TogglePattern)
Catch
' object doesn't support the TogglePattern control pattern
Return Nothing
End Try
Return togglePattern
End Function 'GetTogglePattern
///--------------------------------------------------------------------
/// <summary>
/// Calls the TogglePattern.Toggle() method for an associated
/// automation element.
/// </summary>
/// <param name="togglePattern">
/// The TogglePattern control pattern obtained from
/// an automation element.
/// </param>
///--------------------------------------------------------------------
private void ToggleElement(TogglePattern togglePattern)
{
try
{
togglePattern.Toggle();
}
catch (InvalidOperationException)
{
// object is not able to perform the requested action
return;
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TogglePattern.Toggle() method for an associated
''' automation element.
''' </summary>
''' <param name="togglePattern">
''' The TogglePattern control pattern obtained from
''' an automation element.
''' </param>
'''--------------------------------------------------------------------
Private Sub ToggleElement(ByVal togglePattern As TogglePattern)
Try
togglePattern.Toggle()
Catch
' object is not able to perform the requested action
Return
End Try
End Sub
설명
컨트롤을 번갈아 표시 해당 ToggleState 순서로: On, Off 지원 되는 경우 Indeterminate합니다.