Compartir a través de


PendingFocusHelper.SetFocusOnLoad Method

Sets focus on the last element pending focus on the Loaded event, all previous elements will not be focused.

Namespace:  Microsoft.VisualStudio.PlatformUI
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

Syntax

'Declaration
Public Shared Sub SetFocusOnLoad ( _
    element As FrameworkElement, _
    focusAction As Action(Of FrameworkElement) _
)
public static void SetFocusOnLoad(
    FrameworkElement element,
    Action<FrameworkElement> focusAction
)
public:
static void SetFocusOnLoad(
    FrameworkElement^ element, 
    Action<FrameworkElement^>^ focusAction
)
static member SetFocusOnLoad : 
        element:FrameworkElement * 
        focusAction:Action<FrameworkElement> -> unit
public static function SetFocusOnLoad(
    element : FrameworkElement, 
    focusAction : Action<FrameworkElement>
)

Parameters

  • element
    Type: FrameworkElement

    The element to set focus on.

  • focusAction
    Type: Action<FrameworkElement>

    The action to perform when the focus is on.

Remarks

Either sends focus to the FrameworkElement immediately using Focus, or delays focusing the FrameworkElement until it is loaded. The last element pending focus on Loaded will be focused, and all previous FrameworkElements will not be focused. If UIElement.MoveFocus fails to move focus into the element, focus will be cleared by invoking Keyboard.ClearFocus to clear WPF focus, and by using SetFocus to focus the HWND of HwndSource containing the element.

.NET Framework Security

See Also

Reference

PendingFocusHelper Class

Microsoft.VisualStudio.PlatformUI Namespace