CoreInputView.XYFocusTransferringFromPrimaryView CoreInputView.XYFocusTransferringFromPrimaryView CoreInputView.XYFocusTransferringFromPrimaryView CoreInputView.XYFocusTransferringFromPrimaryView CoreInputView.XYFocusTransferringFromPrimaryView Event

Definition

Occurs before the input pane loses focus and before a UI element gets focus.

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

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

// Revoke with event_revoker
XYFocusTransferringFromPrimaryView_revoker XYFocusTransferringFromPrimaryView(auto_revoke_t, TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs> const& handler) const;
public event TypedEventHandler<CoreInputView, CoreInputViewTransferringXYFocusEventArgs> XYFocusTransferringFromPrimaryView
Public Event XYFocusTransferringFromPrimaryView As TypedEventHandler (Of CoreInputView, CoreInputViewTransferringXYFocusEventArgs)
function onXYFocusTransferringFromPrimaryView(eventArgs){/* Your code */}


coreInputView.addEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);
coreInputView.removeEventListener("xyfocustransferringfromprimaryview", onXYFocusTransferringFromPrimaryView);

Examples

Here, we show how to handle the XYFocusTransferringFromPrimaryView event and identify which UI element should receive focus in the application. The focus candidates are differentiated based on location relative to the bounding rect of the last input pane child element.

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; 
    } 
} 

Remarks

Designate the focus target when navigating from the input pane to a UI element in your application.

See also