LosingFocusEventArgs.TrySetNewFocusedElement(DependencyObject) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attempts to redirect focus from the targeted element to the specified element.
public:
virtual bool TrySetNewFocusedElement(DependencyObject ^ element) = TrySetNewFocusedElement;
bool TrySetNewFocusedElement(DependencyObject const& element);
public bool TrySetNewFocusedElement(DependencyObject element);
function trySetNewFocusedElement(element)
Public Function TrySetNewFocusedElement (element As DependencyObject) As Boolean
Parameters
- element
- DependencyObject
The object on which to set focus.
Returns
bool
true
if the focus action is redirected; otherwise, false
.
Remarks
The GotFocus routed event is raised on an element after it receives focus, while the LostFocus routed event is raised on an element after it loses focus.
The GettingFocus and LosingFocus routed events occur before the focus change takes place, which enables your application to modify or cancel the focus change behavior.
GettingFocus and LosingFocus are raised synchronously, while GotFocus and LostFocus are raised asynchronously. For example, if your app calls the Focus method of a control, GettingFocus
is raised during the call, but GotFocus is raised after the call completes.
If focus is moved while these events are still bubbling, an exception is thrown.