FrameworkElement.MoveFocus(TraversalRequest) Yöntem

Tanım

Klavye odağını bu öğeden uzağa ve sağlanan geçiş yönündeki başka bir öğeye taşır.

C#
public override sealed bool MoveFocus (System.Windows.Input.TraversalRequest request);

Parametreler

request
TraversalRequest

Odağın taşınacağı yön, sabit listesi değeri olarak.

Döndürülenler

Boolean

Odak başarıyla taşınırsa, false belirtilen yönde hedef öğe yoksa veya klavye odaklı olamazsa döndürürtrue.

Örnekler

Aşağıdaki örnek, birkaç olası düğme girişini işleyen bir işleyici uygular. Her düğme olası FocusNavigationDirectionbir öğesini temsil eder. İşleyici, geçerli klavye odağıyla öğeyi izler ve sağlanan tür parametresi için uygun FocusNavigationDirection başlatmayı belirterek bu öğeyi TraversalRequest çağırırMoveFocus.

C#
// Creating a FocusNavigationDirection object and setting it to a
// local field that contains the direction selected.
FocusNavigationDirection focusDirection = _focusMoveValue;

// MoveFocus takes a TraveralReqest as its argument.
TraversalRequest request = new TraversalRequest(focusDirection);

// Gets the element with keyboard focus.
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;

// Change keyboard focus.
if (elementWithFocus != null)
{
    elementWithFocus.MoveFocus(request);
}

Açıklamalar

Bu uygulama, yöntemini geçersiz kılar UIElement.MoveFocus ve mühürler.

Şunlara uygulanır

Ürün Sürümler
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Ayrıca bkz.