Partager via


CoreInputView.XYFocusTransferringFromPrimaryView Événement

Définition

Se produit avant que le volet d’entrée perde le focus et avant qu’un élément d’interface utilisateur n’obtienne le focus.

// Register
event_token XYFocusTransferringFromPrimaryView(TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs const&> const& handler) const;

// Revoke with event_token
void XYFocusTransferringFromPrimaryView(event_token const* cookie) const;

// Revoke with event_revoker
CoreInputView::XYFocusTransferringFromPrimaryView_revoker XYFocusTransferringFromPrimaryView(auto_revoke_t, TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs const&> const& handler) const;
public event TypedEventHandler<CoreInputView,CoreInputViewTransferringXYFocusEventArgs> XYFocusTransferringFromPrimaryView;
function onXYFocusTransferringFromPrimaryView(eventArgs) { /* Your code */ }
coreInputView.addEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);
coreInputView.removeEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);
- or -
coreInputView.onxyfocustransferringfromprimaryview = onXYFocusTransferringFromPrimaryView;
Public Custom Event XYFocusTransferringFromPrimaryView As TypedEventHandler(Of CoreInputView, CoreInputViewTransferringXYFocusEventArgs) 

Type d'événement

Configuration requise pour Windows

Famille d’appareils
Windows 10, version 1803 (introduit dans 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v6.0)

Exemples

Ici, nous montrons comment gérer l’événement XYFocusTransferringFromPrimaryView et identifier l’élément d’interface utilisateur qui doit recevoir le focus dans l’application. Les candidats au focus sont différenciés en fonction de l’emplacement par rapport au rect englobant du dernier élément enfant du volet d’entrée.

private void OnXYFocusTransferringFromPrimaryView(CoreInputView sender,
CoreInputViewTransferringXYFocusEventArgs args)
{
    bool acceptXYFocusTransfer = false;

    switch (args.Direction)
    {
        case CoreInputViewXYFocusTransferDirection.Down:
            // If focus navigation is moving down,
            // set focus to the top element (usernameTextBox).
            this.usernameTextBox.Focus(FocusState.Programmatic);
            acceptXYFocusTransfer = true;
            break;

        case CoreInputViewXYFocusTransferDirection.Up:
            // If focus navigation is moving up,
            // there are two focus candidates.
            // Check the Origin rect to determine the more
            // suitable candidate.
            if ((args.Origin.X + (args.Origin.Width / 2.0)) <
            Window.Current.Bounds.Width / 2.0)
            {
            this.cancelButton.Focus(FocusState.Programmatic);
            }
            else
            {
            this.submitButton.Focus(FocusState.Programmatic);
            }
            acceptXYFocusTransfer = true;
            break;

        case CoreInputViewXYFocusTransferDirection.Left:
        case CoreInputViewXYFocusTransferDirection.Right:
            // If focus navigation is moving left or right,
            // maintain focus on the currently focused UI element.
            acceptXYFocusTransfer = true;
            break;

        default:
            // Don't accept XY focus movement.
            break;
    }

    if (acceptXYFocusTransfer)
    {
        args.TransferHandled = true;
        this.KeyDown += OnMainPageKeyDown;
    }
}

Remarques

La vue principale fait référence aux vues CoreInputViewKind.Keyboard ou CoreInputViewKind.Handwriting , tandis que CoreInputView peut être l’une des valeurs de CoreInputViewKind.

Désignez la cible de focus lors de la navigation à partir du volet d’entrée vers un élément d’interface utilisateur dans votre application.

S’applique à

Voir aussi