PendingFocusHelper::SetFocusOnLoad Method (FrameworkElement^, Action<FrameworkElement^>^)

 

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.14.0 (in Microsoft.VisualStudio.Shell.14.0.dll)

public:
static void SetFocusOnLoad(
	FrameworkElement^ element,
	Action<FrameworkElement^>^ focusAction = null
)

Parameters

element
Type: System.Windows::FrameworkElement^

The element to set focus on.

focusAction
Type: System::Action<FrameworkElement^>^

The action to perform when the focus is on.

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.

Return to top
Show: