FocusOnKeyboardInput property

SearchBox.FocusOnKeyboardInput property

Gets or sets a value that determines whether a user can search by typing anywhere in the app.


public bool FocusOnKeyboardInput { get; set; }

<SearchBox FocusOnKeyboardInput="bool"/>

Property value

Type: System.Boolean [.NET] | Platform::Boolean [C++]

true if the user can search by typing anywhere in the app; otherwise, false. The default is false.



When FocusOnKeyboardInput is set to true, there’s an issue that sometimes creates duplicate characters in the SearchBox control when using the touch keyboard. You can work around the issue by following these steps:

  1. Disable FocusOnKeyboardInput after the SearchBox receives focus. To do this, register for the PrepareForFocusOnKeyboardInput event and use the event handler to set FocusOnKeyboardInput to false.
  2. When the SearchBox loses focus, set FocusOnKeyboardInput back to true. To do this, register for the LostFocus event and use the event handler to set FocusOnKeyboardInput back to true.

When FocusOnKeyboardInput is true, keyboard input on the current thread is intercepted and textual input is redirected to the SearchBox. Only textual input will cause the SearchBox to receive focus. Non-text keys, such as arrows or Tab, are not redirected to the SearchBox. WIN/CTRL/ALT key combinations (except for Ctrl-V for paste) are also not redirected.

To do more than just set focus in the SearchBox, such as make the control visible, handle the PrepareForFocusOnKeyboardInput event.

You should set FocusOnKeyboardInput to false if the user sets focus on some other editable text field.

To learn more about when you should let users type to search, see Guidelines and checklist for search.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml::Controls [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

None supported


Windows::UI::Xaml::Controls [C++]



See also

Guidelines and checklist for search



© 2017 Microsoft