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 則是以非同步方式引發。 例如,如果您的 app 呼叫控制項的 Focus 方法, GettingFocus 則會在呼叫期間引發,但在呼叫完成後會引發 GotFocus

如果在這些事件仍在反升時移動焦點,則會擲回例外狀況。

適用於

另請參閱