LosingFocusEventArgs.TrySetNewFocusedElement(DependencyObject) 方法

定义

尝试将焦点从目标元素重定向到指定的元素。

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

参数

element
DependencyObject

要设置焦点的对象。

返回

Boolean

bool

true 如果重定向焦点操作,则为 ;否则为 false

注解

GotFocus 路由事件在获得焦点后在元素上引发,而 LostFocus 路由事件在元素失去焦点后在元素上引发。

GettingFocusLosingFocus 路由事件在焦点更改发生之前发生,这使应用程序能够修改或取消焦点更改行为。

GettingFocusLosingFocus 是同步引发的,而 GotFocusLostFocus 是异步引发的。 例如,如果应用调用控件的 Focus 方法, GettingFocus 则会在调用期间引发 ,但在调用完成后会引发 GotFocus

如果在这些事件仍在冒泡时移动焦点,则会引发异常。

适用于

另请参阅