SearchBox SearchBox SearchBox Class

Definition

Represents a control that can be used to enter search query text. (Not recommended for Universal Windows Platform (UWP) apps. See AutoSuggestBox.)

public : class SearchBox : Control, ISearchBox
public class SearchBox : Control, ISearchBox
Public Class SearchBox Inherits Control Implements ISearchBox
<SearchBox .../>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

Here's a basic XAML definition for a SearchBox, and an implementation of the QuerySubmitted handler. It calls Frame.Navigate to load a search query result page (not shown) that's named SearchResultsPage1. The this/Me reference in the handlers is the containing page instance, as is typical for on-page input event handling code. You can see similar code as part of Quickstart: Adding search to an app.

<SearchBox x:Name="mySearchBox" 
    FocusOnKeyboardInput="True"
    QuerySubmitted="mySearchBox_QuerySubmitted"
    Height="35"/>
private void mySearchBox_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args)
{
    this.Frame.Navigate(typeof(SearchResultsPage1), args.QueryText);
}
Private Sub mySearchBox_QuerySubmitted(sender As SearchBox, args As SearchBoxQuerySubmittedEventArgs)
    Me.Frame.Navigate(GetType(SearchResultsPage1), args.QueryText)
End Sub

Remarks

Windows 10

Important

Although SearchBox is implemented in the Universal device family, it is not fully functional on mobile devices. Use AutoSuggestBox for your universal search experience. See SearchBox deprecated in favor of AutoSuggestBox.

Windows 8.x

To support keyboard interaction and make your app's search experience consistent with the Start screen, set the FocusOnKeyboardInput property to true. For more info, see Guidelines and checklist for search.

At a minimum each SearchBox control should always have a QuerySubmitted handler. This handler passes the user's query text to a search results page that the handler opens. Open this page by calling Frame.Navigate. For more info on how to write a basic QuerySubmitted handler and create a search results page as part of your app, see Enabling users to search for information in your .

In addition to the basic results and search experience, a SearchBox also supports search suggestions, programmatically setting the starting search text, and search history. The search suggestion feature is supported by API in the Windows.ApplicationModel.Search namespace. For example code that shows how to use these features, see SearchBox control sample.

Note

An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for UWP app using C++, C#, or Visual Basic, WinJS.UI.SearchBox for Windows app using JavaScript) and the SearchPane. Using both the search box and the search pane in the same app causes the app to throw an exception with this message: "Cannot create instance of type 'Windows.UI.Xaml.Controls.SearchBox'"

Constructors

SearchBox() SearchBox() SearchBox()

Initializes a new instance of the SearchBox class.

public : SearchBox()
public SearchBox()
Public Sub New()

Properties

AccessKey AccessKey AccessKey

Inherited from UIElement

AccessKeyProperty AccessKeyProperty AccessKeyProperty

Inherited from UIElement

AccessKeyScopeOwner AccessKeyScopeOwner AccessKeyScopeOwner

Inherited from UIElement

AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty

Inherited from UIElement

ActualHeight ActualHeight ActualHeight

Inherited from FrameworkElement

ActualHeightProperty ActualHeightProperty ActualHeightProperty

Inherited from FrameworkElement

ActualTheme ActualTheme ActualTheme

Inherited from FrameworkElement

ActualThemeProperty ActualThemeProperty ActualThemeProperty

Inherited from FrameworkElement

ActualWidth ActualWidth ActualWidth

Inherited from FrameworkElement

ActualWidthProperty ActualWidthProperty ActualWidthProperty

Inherited from FrameworkElement

AllowDrop AllowDrop AllowDrop

Inherited from UIElement

AllowDropProperty AllowDropProperty AllowDropProperty

Inherited from UIElement

AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction

Inherited from FrameworkElement

AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty

Inherited from FrameworkElement

AllowFocusWhenDisabled AllowFocusWhenDisabled AllowFocusWhenDisabled

Inherited from FrameworkElement

AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty

Inherited from FrameworkElement

Background Background Background

Inherited from Control

BackgroundProperty BackgroundProperty BackgroundProperty

Inherited from Control

BaseUri BaseUri BaseUri

Inherited from FrameworkElement

BorderBrush BorderBrush BorderBrush

Inherited from Control

BorderBrushProperty BorderBrushProperty BorderBrushProperty

Inherited from Control

BorderThickness BorderThickness BorderThickness

Inherited from Control

BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty

Inherited from Control

CacheMode CacheMode CacheMode

Inherited from UIElement

CacheModeProperty CacheModeProperty CacheModeProperty

Inherited from UIElement

CanDrag CanDrag CanDrag

Inherited from UIElement

CanDragProperty CanDragProperty CanDragProperty

Inherited from UIElement

CharacterReceivedEvent CharacterReceivedEvent CharacterReceivedEvent

Inherited from UIElement

CharacterSpacing CharacterSpacing CharacterSpacing

Inherited from Control

CharacterSpacingProperty CharacterSpacingProperty CharacterSpacingProperty

Inherited from Control

ChooseSuggestionOnEnter ChooseSuggestionOnEnter ChooseSuggestionOnEnter

Gets or sets a value that determines whether the suggested search query is activated when the user presses Enter.

public : Platform::Boolean ChooseSuggestionOnEnter { get; set; }
public bool ChooseSuggestionOnEnter { get; set; }
Public ReadWrite Property ChooseSuggestionOnEnter As bool
<SearchBox ChooseSuggestionOnEnter="bool"/>
Value
Platform::Boolean bool bool

true if the suggested search query is activated when the user presses Enter; otherwise, false. The default is false.

ChooseSuggestionOnEnterProperty ChooseSuggestionOnEnterProperty ChooseSuggestionOnEnterProperty

Identifies the ChooseSuggestionOnEnter dependency property.

public : static DependencyProperty ChooseSuggestionOnEnterProperty { get; }
public static DependencyProperty ChooseSuggestionOnEnterProperty { get; }
Public Static ReadOnly Property ChooseSuggestionOnEnterProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ChooseSuggestionOnEnter dependency property.

Clip Clip Clip

Inherited from UIElement

ClipProperty ClipProperty ClipProperty

Inherited from UIElement

CompositeMode CompositeMode CompositeMode

Inherited from UIElement

CompositeModeProperty CompositeModeProperty CompositeModeProperty

Inherited from UIElement

ContextFlyout ContextFlyout ContextFlyout

Inherited from UIElement

ContextFlyoutProperty ContextFlyoutProperty ContextFlyoutProperty

Inherited from UIElement

DataContext DataContext DataContext

Inherited from FrameworkElement

DataContextProperty DataContextProperty DataContextProperty

Inherited from FrameworkElement

DefaultStyleKey DefaultStyleKey DefaultStyleKey

Inherited from Control

DefaultStyleKeyProperty DefaultStyleKeyProperty DefaultStyleKeyProperty

Inherited from Control

DefaultStyleResourceUri DefaultStyleResourceUri DefaultStyleResourceUri

Inherited from Control

DefaultStyleResourceUriProperty DefaultStyleResourceUriProperty DefaultStyleResourceUriProperty

Inherited from Control

DesiredSize DesiredSize DesiredSize

Inherited from UIElement

Dispatcher Dispatcher Dispatcher

Inherited from DependencyObject

DoubleTappedEvent DoubleTappedEvent DoubleTappedEvent

Inherited from UIElement

DragEnterEvent DragEnterEvent DragEnterEvent

Inherited from UIElement

DragLeaveEvent DragLeaveEvent DragLeaveEvent

Inherited from UIElement

DragOverEvent DragOverEvent DragOverEvent

Inherited from UIElement

DropEvent DropEvent DropEvent

Inherited from UIElement

ElementSoundMode ElementSoundMode ElementSoundMode

Inherited from Control

ElementSoundModeProperty ElementSoundModeProperty ElementSoundModeProperty

Inherited from Control

ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked

Inherited from UIElement

ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty

Inherited from UIElement

FlowDirection FlowDirection FlowDirection

Inherited from FrameworkElement

FlowDirectionProperty FlowDirectionProperty FlowDirectionProperty

Inherited from FrameworkElement

FocusOnKeyboardInput FocusOnKeyboardInput FocusOnKeyboardInput

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

public : Platform::Boolean FocusOnKeyboardInput { get; set; }
public bool FocusOnKeyboardInput { get; set; }
Public ReadWrite Property FocusOnKeyboardInput As bool
<SearchBox FocusOnKeyboardInput="bool"/>
Value
Platform::Boolean bool bool

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

Remarks

Note

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.

See Also

FocusOnKeyboardInputProperty FocusOnKeyboardInputProperty FocusOnKeyboardInputProperty

Identifies the FocusOnKeyboardInput dependency property.

public : static DependencyProperty FocusOnKeyboardInputProperty { get; }
public static DependencyProperty FocusOnKeyboardInputProperty { get; }
Public Static ReadOnly Property FocusOnKeyboardInputProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FocusOnKeyboardInput dependency property.

Remarks

Note

When FocusOnKeyboardInput is set to true, there’s an issue that sometimes causes users to see duplicate characters in the SearchBox control when using the touch keyboard. You can work around the issue by following these steps: 1. Register for the PrepareForFocusOnKeyboardInput event and use the event handler to set FocusOnKeyboardInput to false. 2. Register for the LostFocus event and use the event handler to set FocusOnKeyboardInput back to true.

FocusState FocusState FocusState

Inherited from Control

FocusStateProperty FocusStateProperty FocusStateProperty

Inherited from Control

FocusVisualMargin FocusVisualMargin FocusVisualMargin

Inherited from FrameworkElement

FocusVisualMarginProperty FocusVisualMarginProperty FocusVisualMarginProperty

Inherited from FrameworkElement

FocusVisualPrimaryBrush FocusVisualPrimaryBrush FocusVisualPrimaryBrush

Inherited from FrameworkElement

FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty

Inherited from FrameworkElement

FocusVisualPrimaryThickness FocusVisualPrimaryThickness FocusVisualPrimaryThickness

Inherited from FrameworkElement

FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty

Inherited from FrameworkElement

FocusVisualSecondaryBrush FocusVisualSecondaryBrush FocusVisualSecondaryBrush

Inherited from FrameworkElement

FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty

Inherited from FrameworkElement

FocusVisualSecondaryThickness FocusVisualSecondaryThickness FocusVisualSecondaryThickness

Inherited from FrameworkElement

FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty

Inherited from FrameworkElement

FontFamily FontFamily FontFamily

Inherited from Control

FontFamilyProperty FontFamilyProperty FontFamilyProperty

Inherited from Control

FontSize FontSize FontSize

Inherited from Control

FontSizeProperty FontSizeProperty FontSizeProperty

Inherited from Control

FontStretch FontStretch FontStretch

Inherited from Control

FontStretchProperty FontStretchProperty FontStretchProperty

Inherited from Control

FontStyle FontStyle FontStyle

Inherited from Control

FontStyleProperty FontStyleProperty FontStyleProperty

Inherited from Control

FontWeight FontWeight FontWeight

Inherited from Control

FontWeightProperty FontWeightProperty FontWeightProperty

Inherited from Control

Foreground Foreground Foreground

Inherited from Control

ForegroundProperty ForegroundProperty ForegroundProperty

Inherited from Control

GettingFocusEvent GettingFocusEvent GettingFocusEvent

Inherited from UIElement

Height Height Height

Inherited from FrameworkElement

HeightProperty HeightProperty HeightProperty

Inherited from FrameworkElement

HighContrastAdjustment HighContrastAdjustment HighContrastAdjustment

Inherited from UIElement

HighContrastAdjustmentProperty HighContrastAdjustmentProperty HighContrastAdjustmentProperty

Inherited from UIElement

HoldingEvent HoldingEvent HoldingEvent

Inherited from UIElement

HorizontalAlignment HorizontalAlignment HorizontalAlignment

Inherited from FrameworkElement

HorizontalAlignmentProperty HorizontalAlignmentProperty HorizontalAlignmentProperty

Inherited from FrameworkElement

HorizontalContentAlignment HorizontalContentAlignment HorizontalContentAlignment

Inherited from Control

HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty

Inherited from Control

IsAccessKeyScope IsAccessKeyScope IsAccessKeyScope

Inherited from UIElement

IsAccessKeyScopeProperty IsAccessKeyScopeProperty IsAccessKeyScopeProperty

Inherited from UIElement

IsDoubleTapEnabled IsDoubleTapEnabled IsDoubleTapEnabled

Inherited from UIElement

IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty

Inherited from UIElement

IsEnabled IsEnabled IsEnabled

Inherited from Control

IsEnabledProperty IsEnabledProperty IsEnabledProperty

Inherited from Control

IsFocusEngaged IsFocusEngaged IsFocusEngaged

Inherited from Control

IsFocusEngagedProperty IsFocusEngagedProperty IsFocusEngagedProperty

Inherited from Control

IsFocusEngagementEnabled IsFocusEngagementEnabled IsFocusEngagementEnabled

Inherited from Control

IsFocusEngagementEnabledProperty IsFocusEngagementEnabledProperty IsFocusEngagementEnabledProperty

Inherited from Control

IsHitTestVisible IsHitTestVisible IsHitTestVisible

Inherited from UIElement

IsHitTestVisibleProperty IsHitTestVisibleProperty IsHitTestVisibleProperty

Inherited from UIElement

IsHoldingEnabled IsHoldingEnabled IsHoldingEnabled

Inherited from UIElement

IsHoldingEnabledProperty IsHoldingEnabledProperty IsHoldingEnabledProperty

Inherited from UIElement

IsRightTapEnabled IsRightTapEnabled IsRightTapEnabled

Inherited from UIElement

IsRightTapEnabledProperty IsRightTapEnabledProperty IsRightTapEnabledProperty

Inherited from UIElement

IsTabStop IsTabStop IsTabStop

Inherited from Control

IsTabStopProperty IsTabStopProperty IsTabStopProperty

Inherited from Control

IsTapEnabled IsTapEnabled IsTapEnabled

Inherited from UIElement

IsTapEnabledProperty IsTapEnabledProperty IsTapEnabledProperty

Inherited from UIElement

IsTemplateFocusTargetProperty IsTemplateFocusTargetProperty IsTemplateFocusTargetProperty

Inherited from Control

IsTemplateKeyTipTargetProperty IsTemplateKeyTipTargetProperty IsTemplateKeyTipTargetProperty

Inherited from Control

IsTextScaleFactorEnabled IsTextScaleFactorEnabled IsTextScaleFactorEnabled

Inherited from Control

IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty

Inherited from Control

KeyDownEvent KeyDownEvent KeyDownEvent

Inherited from UIElement

KeyTipHorizontalOffset KeyTipHorizontalOffset KeyTipHorizontalOffset

Inherited from UIElement

KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty

Inherited from UIElement

KeyTipPlacementMode KeyTipPlacementMode KeyTipPlacementMode

Inherited from UIElement

KeyTipPlacementModeProperty KeyTipPlacementModeProperty KeyTipPlacementModeProperty

Inherited from UIElement

KeyTipVerticalOffset KeyTipVerticalOffset KeyTipVerticalOffset

Inherited from UIElement

KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty

Inherited from UIElement

KeyUpEvent KeyUpEvent KeyUpEvent

Inherited from UIElement

KeyboardAccelerators KeyboardAccelerators KeyboardAccelerators

Inherited from UIElement

Language Language Language

Inherited from FrameworkElement

LanguageProperty LanguageProperty LanguageProperty

Inherited from FrameworkElement

Lights Lights Lights

Inherited from UIElement

LightsProperty LightsProperty LightsProperty

Inherited from UIElement

LosingFocusEvent LosingFocusEvent LosingFocusEvent

Inherited from UIElement

ManipulationCompletedEvent ManipulationCompletedEvent ManipulationCompletedEvent

Inherited from UIElement

ManipulationDeltaEvent ManipulationDeltaEvent ManipulationDeltaEvent

Inherited from UIElement

ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent

Inherited from UIElement

ManipulationMode ManipulationMode ManipulationMode

Inherited from UIElement

ManipulationModeProperty ManipulationModeProperty ManipulationModeProperty

Inherited from UIElement

ManipulationStartedEvent ManipulationStartedEvent ManipulationStartedEvent

Inherited from UIElement

ManipulationStartingEvent ManipulationStartingEvent ManipulationStartingEvent

Inherited from UIElement

Margin Margin Margin

Inherited from FrameworkElement

MarginProperty MarginProperty MarginProperty

Inherited from FrameworkElement

MaxHeight MaxHeight MaxHeight

Inherited from FrameworkElement

MaxHeightProperty MaxHeightProperty MaxHeightProperty

Inherited from FrameworkElement

MaxWidth MaxWidth MaxWidth

Inherited from FrameworkElement

MaxWidthProperty MaxWidthProperty MaxWidthProperty

Inherited from FrameworkElement

MinHeight MinHeight MinHeight

Inherited from FrameworkElement

MinHeightProperty MinHeightProperty MinHeightProperty

Inherited from FrameworkElement

MinWidth MinWidth MinWidth

Inherited from FrameworkElement

MinWidthProperty MinWidthProperty MinWidthProperty

Inherited from FrameworkElement

Name Name Name

Inherited from FrameworkElement

NameProperty NameProperty NameProperty

Inherited from FrameworkElement

NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent

Inherited from UIElement

Opacity Opacity Opacity

Inherited from UIElement

OpacityProperty OpacityProperty OpacityProperty

Inherited from UIElement

Padding Padding Padding

Inherited from Control

PaddingProperty PaddingProperty PaddingProperty

Inherited from Control

Parent Parent Parent

Inherited from FrameworkElement

PlaceholderText PlaceholderText PlaceholderText

Gets or sets the text that is displayed in the control until the value is changed by a user action or some other operation.

public : Platform::String PlaceholderText { get; set; }
public string PlaceholderText { get; set; }
Public ReadWrite Property PlaceholderText As string
<SearchBox PlaceholderText="placeholderString"/>

Value
Platform::String string string

The text that is displayed in the control when no value is entered. The default is an empty string (""). The maximum placeholder text length is 128 characters.

PlaceholderTextProperty PlaceholderTextProperty PlaceholderTextProperty

Identifies the PlaceholderText dependency property.

public : static DependencyProperty PlaceholderTextProperty { get; }
public static DependencyProperty PlaceholderTextProperty { get; }
Public Static ReadOnly Property PlaceholderTextProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the PlaceholderText dependency property.

PointerCanceledEvent PointerCanceledEvent PointerCanceledEvent

Inherited from UIElement

PointerCaptureLostEvent PointerCaptureLostEvent PointerCaptureLostEvent

Inherited from UIElement

PointerCaptures PointerCaptures PointerCaptures

Inherited from UIElement

PointerCapturesProperty PointerCapturesProperty PointerCapturesProperty

Inherited from UIElement

PointerEnteredEvent PointerEnteredEvent PointerEnteredEvent

Inherited from UIElement

PointerExitedEvent PointerExitedEvent PointerExitedEvent

Inherited from UIElement

PointerMovedEvent PointerMovedEvent PointerMovedEvent

Inherited from UIElement

PointerPressedEvent PointerPressedEvent PointerPressedEvent

Inherited from UIElement

PointerReleasedEvent PointerReleasedEvent PointerReleasedEvent

Inherited from UIElement

PointerWheelChangedEvent PointerWheelChangedEvent PointerWheelChangedEvent

Inherited from UIElement

PreviewKeyDownEvent PreviewKeyDownEvent PreviewKeyDownEvent

Inherited from UIElement

PreviewKeyUpEvent PreviewKeyUpEvent PreviewKeyUpEvent

Inherited from UIElement

Projection Projection Projection

Inherited from UIElement

ProjectionProperty ProjectionProperty ProjectionProperty

Inherited from UIElement

QueryText QueryText QueryText

Gets or sets the text contents of the search box.

public : Platform::String QueryText { get; set; }
public string QueryText { get; set; }
Public ReadWrite Property QueryText As string
<SearchBox QueryText="string"/>
Value
Platform::String string string

A string containing the text contents of the search box. The default is an empty string (""). The maximum query text length is 2048 characters.

QueryTextProperty QueryTextProperty QueryTextProperty

Identifies the QueryText dependency property.

public : static DependencyProperty QueryTextProperty { get; }
public static DependencyProperty QueryTextProperty { get; }
Public Static ReadOnly Property QueryTextProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the QueryText dependency property.

RenderSize RenderSize RenderSize

Inherited from UIElement

RenderTransform RenderTransform RenderTransform

Inherited from UIElement

RenderTransformOrigin RenderTransformOrigin RenderTransformOrigin

Inherited from UIElement

RenderTransformOriginProperty RenderTransformOriginProperty RenderTransformOriginProperty

Inherited from UIElement

RenderTransformProperty RenderTransformProperty RenderTransformProperty

Inherited from UIElement

RequestedTheme RequestedTheme RequestedTheme

Inherited from FrameworkElement

RequestedThemeProperty RequestedThemeProperty RequestedThemeProperty

Inherited from FrameworkElement

RequiresPointer RequiresPointer RequiresPointer

Inherited from Control

RequiresPointerProperty RequiresPointerProperty RequiresPointerProperty

Inherited from Control

Resources Resources Resources

Inherited from FrameworkElement

RightTappedEvent RightTappedEvent RightTappedEvent

Inherited from UIElement

SearchHistoryContext SearchHistoryContext SearchHistoryContext

Gets or sets a string that identifies the context of the search and is used to store the user's search history with the app.

public : Platform::String SearchHistoryContext { get; set; }
public string SearchHistoryContext { get; set; }
Public ReadWrite Property SearchHistoryContext As string
<SearchBox SearchHistoryContext="string"/>
Value
Platform::String string string

A string that identifies the context of the search. The default is an empty string ("").

Remarks

The search history context string is used as a secondary key for storing search history. The primary key is the AppId. You can use the search history context string to store different search histories for different pages or search entry points in the app. If you don't set this property, Windows assumes that all searches in your app occur in the same context.

SearchHistoryContextProperty SearchHistoryContextProperty SearchHistoryContextProperty

Identifies the SearchHistoryContext dependency property.

public : static DependencyProperty SearchHistoryContextProperty { get; }
public static DependencyProperty SearchHistoryContextProperty { get; }
Public Static ReadOnly Property SearchHistoryContextProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SearchHistoryContext dependency property.

SearchHistoryEnabled SearchHistoryEnabled SearchHistoryEnabled

Gets or sets a value that determines whether search suggestions are made from the search history.

public : Platform::Boolean SearchHistoryEnabled { get; set; }
public bool SearchHistoryEnabled { get; set; }
Public ReadWrite Property SearchHistoryEnabled As bool
<SearchBox SearchHistoryEnabled="bool"/>
Value
Platform::Boolean bool bool

true if search suggestions are made from the search history; otherwise, false. The default is true.

SearchHistoryEnabledProperty SearchHistoryEnabledProperty SearchHistoryEnabledProperty

Identifies the SearchHistoryEnabled dependency property.

public : static DependencyProperty SearchHistoryEnabledProperty { get; }
public static DependencyProperty SearchHistoryEnabledProperty { get; }
Public Static ReadOnly Property SearchHistoryEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SearchHistoryEnabled dependency property.

Style Style Style

Inherited from FrameworkElement

StyleProperty StyleProperty StyleProperty

Inherited from FrameworkElement

TabFocusNavigation TabFocusNavigation TabFocusNavigation

Inherited from UIElement

TabFocusNavigationProperty TabFocusNavigationProperty TabFocusNavigationProperty

Inherited from UIElement

TabIndex TabIndex TabIndex

Inherited from Control

TabIndexProperty TabIndexProperty TabIndexProperty

Inherited from Control

TabNavigation TabNavigation TabNavigation

Inherited from Control

TabNavigationProperty TabNavigationProperty TabNavigationProperty

Inherited from Control

Tag Tag Tag

Inherited from FrameworkElement

TagProperty TagProperty TagProperty

Inherited from FrameworkElement

TappedEvent TappedEvent TappedEvent

Inherited from UIElement

Template Template Template

Inherited from Control

TemplateProperty TemplateProperty TemplateProperty

Inherited from Control

Transform3D Transform3D Transform3D

Inherited from UIElement

Transform3DProperty Transform3DProperty Transform3DProperty

Inherited from UIElement

Transitions Transitions Transitions

Inherited from UIElement

TransitionsProperty TransitionsProperty TransitionsProperty

Inherited from UIElement

Triggers Triggers Triggers

Inherited from FrameworkElement

UseLayoutRounding UseLayoutRounding UseLayoutRounding

Inherited from UIElement

UseLayoutRoundingProperty UseLayoutRoundingProperty UseLayoutRoundingProperty

Inherited from UIElement

UseSystemFocusVisuals UseSystemFocusVisuals UseSystemFocusVisuals

Inherited from Control

UseSystemFocusVisualsProperty UseSystemFocusVisualsProperty UseSystemFocusVisualsProperty

Inherited from Control

VerticalAlignment VerticalAlignment VerticalAlignment

Inherited from FrameworkElement

VerticalAlignmentProperty VerticalAlignmentProperty VerticalAlignmentProperty

Inherited from FrameworkElement

VerticalContentAlignment VerticalContentAlignment VerticalContentAlignment

Inherited from Control

VerticalContentAlignmentProperty VerticalContentAlignmentProperty VerticalContentAlignmentProperty

Inherited from Control

Visibility Visibility Visibility

Inherited from UIElement

VisibilityProperty VisibilityProperty VisibilityProperty

Inherited from UIElement

Width Width Width

Inherited from FrameworkElement

WidthProperty WidthProperty WidthProperty

Inherited from FrameworkElement

XYFocusDown XYFocusDown XYFocusDown

Inherited from Control

XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy

Inherited from UIElement

XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty

Inherited from UIElement

XYFocusDownProperty XYFocusDownProperty XYFocusDownProperty

Inherited from Control

XYFocusKeyboardNavigation XYFocusKeyboardNavigation XYFocusKeyboardNavigation

Inherited from UIElement

XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty

Inherited from UIElement

XYFocusLeft XYFocusLeft XYFocusLeft

Inherited from Control

XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy

Inherited from UIElement

XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty

Inherited from UIElement

XYFocusLeftProperty XYFocusLeftProperty XYFocusLeftProperty

Inherited from Control

XYFocusRight XYFocusRight XYFocusRight

Inherited from Control

XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy

Inherited from UIElement

XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty

Inherited from UIElement

XYFocusRightProperty XYFocusRightProperty XYFocusRightProperty

Inherited from Control

XYFocusUp XYFocusUp XYFocusUp

Inherited from Control

XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy

Inherited from UIElement

XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty

Inherited from UIElement

XYFocusUpProperty XYFocusUpProperty XYFocusUpProperty

Inherited from Control

Methods

AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean)

Inherited from UIElement

ApplyTemplate ApplyTemplate ApplyTemplate

Inherited from Control

Arrange(Rect) Arrange(Rect) Arrange(Rect)

Inherited from UIElement

ArrangeOverride(Size) ArrangeOverride(Size) ArrangeOverride(Size)

Inherited from FrameworkElement

CancelDirectManipulations CancelDirectManipulations CancelDirectManipulations

Inherited from UIElement

CapturePointer(Pointer) CapturePointer(Pointer) CapturePointer(Pointer)

Inherited from UIElement

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Inherited from DependencyObject

DeferTree(DependencyObject) DeferTree(DependencyObject) DeferTree(DependencyObject)

Inherited from FrameworkElement

FindName(String) FindName(String) FindName(String)

Inherited from FrameworkElement

FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect)

Inherited from UIElement

Focus(FocusState) Focus(FocusState) Focus(FocusState)

Inherited from Control

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Inherited from DependencyObject

GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty)

Inherited from FrameworkElement

GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder

Inherited from UIElement

GetIsTemplateFocusTarget(FrameworkElement) GetIsTemplateFocusTarget(FrameworkElement) GetIsTemplateFocusTarget(FrameworkElement)

Inherited from Control

GetIsTemplateKeyTipTarget(DependencyObject) GetIsTemplateKeyTipTarget(DependencyObject) GetIsTemplateKeyTipTarget(DependencyObject)

Inherited from Control

GetTemplateChild(String) GetTemplateChild(String) GetTemplateChild(String)

Inherited from Control

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Inherited from DependencyObject

GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean)

Inherited from FrameworkElement

InvalidateArrange InvalidateArrange InvalidateArrange

Inherited from UIElement

InvalidateMeasure InvalidateMeasure InvalidateMeasure

Inherited from UIElement

Measure(Size) Measure(Size) Measure(Size)

Inherited from UIElement

MeasureOverride(Size) MeasureOverride(Size) MeasureOverride(Size)

Inherited from FrameworkElement

OnApplyTemplate OnApplyTemplate OnApplyTemplate

Inherited from FrameworkElement

OnCharacterReceived(CharacterReceivedRoutedEventArgs) OnCharacterReceived(CharacterReceivedRoutedEventArgs) OnCharacterReceived(CharacterReceivedRoutedEventArgs)

Inherited from Control

OnCreateAutomationPeer OnCreateAutomationPeer OnCreateAutomationPeer

Inherited from UIElement

OnDisconnectVisualChildren OnDisconnectVisualChildren OnDisconnectVisualChildren

Inherited from UIElement

OnDoubleTapped(DoubleTappedRoutedEventArgs) OnDoubleTapped(DoubleTappedRoutedEventArgs) OnDoubleTapped(DoubleTappedRoutedEventArgs)

Inherited from Control

OnDragEnter(DragEventArgs) OnDragEnter(DragEventArgs) OnDragEnter(DragEventArgs)

Inherited from Control

OnDragLeave(DragEventArgs) OnDragLeave(DragEventArgs) OnDragLeave(DragEventArgs)

Inherited from Control

OnDragOver(DragEventArgs) OnDragOver(DragEventArgs) OnDragOver(DragEventArgs)

Inherited from Control

OnDrop(DragEventArgs) OnDrop(DragEventArgs) OnDrop(DragEventArgs)

Inherited from Control

OnGotFocus(RoutedEventArgs) OnGotFocus(RoutedEventArgs) OnGotFocus(RoutedEventArgs)

Inherited from Control

OnHolding(HoldingRoutedEventArgs) OnHolding(HoldingRoutedEventArgs) OnHolding(HoldingRoutedEventArgs)

Inherited from Control

OnKeyDown(KeyRoutedEventArgs) OnKeyDown(KeyRoutedEventArgs) OnKeyDown(KeyRoutedEventArgs)

Inherited from Control

OnKeyUp(KeyRoutedEventArgs) OnKeyUp(KeyRoutedEventArgs) OnKeyUp(KeyRoutedEventArgs)

Inherited from Control

OnLostFocus(RoutedEventArgs) OnLostFocus(RoutedEventArgs) OnLostFocus(RoutedEventArgs)

Inherited from Control

OnManipulationCompleted(ManipulationCompletedRoutedEventArgs) OnManipulationCompleted(ManipulationCompletedRoutedEventArgs) OnManipulationCompleted(ManipulationCompletedRoutedEventArgs)

Inherited from Control

OnManipulationDelta(ManipulationDeltaRoutedEventArgs) OnManipulationDelta(ManipulationDeltaRoutedEventArgs) OnManipulationDelta(ManipulationDeltaRoutedEventArgs)

Inherited from Control

OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs) OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs) OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs)

Inherited from Control

OnManipulationStarted(ManipulationStartedRoutedEventArgs) OnManipulationStarted(ManipulationStartedRoutedEventArgs) OnManipulationStarted(ManipulationStartedRoutedEventArgs)

Inherited from Control

OnManipulationStarting(ManipulationStartingRoutedEventArgs) OnManipulationStarting(ManipulationStartingRoutedEventArgs) OnManipulationStarting(ManipulationStartingRoutedEventArgs)

Inherited from Control

OnPointerCanceled(PointerRoutedEventArgs) OnPointerCanceled(PointerRoutedEventArgs) OnPointerCanceled(PointerRoutedEventArgs)

Inherited from Control

OnPointerCaptureLost(PointerRoutedEventArgs) OnPointerCaptureLost(PointerRoutedEventArgs) OnPointerCaptureLost(PointerRoutedEventArgs)

Inherited from Control

OnPointerEntered(PointerRoutedEventArgs) OnPointerEntered(PointerRoutedEventArgs) OnPointerEntered(PointerRoutedEventArgs)

Inherited from Control

OnPointerExited(PointerRoutedEventArgs) OnPointerExited(PointerRoutedEventArgs) OnPointerExited(PointerRoutedEventArgs)

Inherited from Control

OnPointerMoved(PointerRoutedEventArgs) OnPointerMoved(PointerRoutedEventArgs) OnPointerMoved(PointerRoutedEventArgs)

Inherited from Control

OnPointerPressed(PointerRoutedEventArgs) OnPointerPressed(PointerRoutedEventArgs) OnPointerPressed(PointerRoutedEventArgs)

Inherited from Control

OnPointerReleased(PointerRoutedEventArgs) OnPointerReleased(PointerRoutedEventArgs) OnPointerReleased(PointerRoutedEventArgs)

Inherited from Control

OnPointerWheelChanged(PointerRoutedEventArgs) OnPointerWheelChanged(PointerRoutedEventArgs) OnPointerWheelChanged(PointerRoutedEventArgs)

Inherited from Control

OnPreviewKeyDown(KeyRoutedEventArgs) OnPreviewKeyDown(KeyRoutedEventArgs) OnPreviewKeyDown(KeyRoutedEventArgs)

Inherited from Control

OnPreviewKeyUp(KeyRoutedEventArgs) OnPreviewKeyUp(KeyRoutedEventArgs) OnPreviewKeyUp(KeyRoutedEventArgs)

Inherited from Control

OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs)

Inherited from UIElement

OnRightTapped(RightTappedRoutedEventArgs) OnRightTapped(RightTappedRoutedEventArgs) OnRightTapped(RightTappedRoutedEventArgs)

Inherited from Control

OnTapped(TappedRoutedEventArgs) OnTapped(TappedRoutedEventArgs) OnTapped(TappedRoutedEventArgs)

Inherited from Control

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Inherited from DependencyObject

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Inherited from DependencyObject

ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer)

Inherited from UIElement

ReleasePointerCaptures ReleasePointerCaptures ReleasePointerCaptures

Inherited from UIElement

RemoveFocusEngagement RemoveFocusEngagement RemoveFocusEngagement

Inherited from Control

RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object)

Inherited from UIElement

SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase)

Inherited from FrameworkElement

SetIsTemplateFocusTarget(FrameworkElement,Boolean) SetIsTemplateFocusTarget(FrameworkElement,Boolean) SetIsTemplateFocusTarget(FrameworkElement,Boolean)

Inherited from Control

SetIsTemplateKeyTipTarget(DependencyObject,Boolean) SetIsTemplateKeyTipTarget(DependencyObject,Boolean) SetIsTemplateKeyTipTarget(DependencyObject,Boolean)

Inherited from Control

SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings)

Specifies whether suggestions based on local files are automatically displayed in the search box suggestions, and defines the criteria that Windows uses to locate and filter these suggestions.

public : void SetLocalContentSuggestionSettings(LocalContentSuggestionSettings settings)
public void SetLocalContentSuggestionSettings(LocalContentSuggestionSettings settings)
Public Function SetLocalContentSuggestionSettings(settings As LocalContentSuggestionSettings) As void
Parameters
settings
LocalContentSuggestionSettings LocalContentSuggestionSettings LocalContentSuggestionSettings

The new settings for local content suggestions.

Examples

Here, suggestions are restricted to one kind of file, music files, using an AQS string. Two of the most common AQS filters restrict based on file kind, like "kind:music" in the example; and based on file name extension, like "ext:.mp3". You can learn more about AQS in Advanced Query Syntax.

public MainPage()
{
    this.InitializeComponent();

    // Let Windows provide suggestions from local files.
    var settings = new Windows.ApplicationModel.Search.LocalContentSuggestionSettings();
    settings.Enabled = true;
    // Access to the music library requires that the Music Library capability
    // be declared in the app manifest .
    settings.Locations.Add(Windows.Storage.KnownFolders.MusicLibrary);
    settings.AqsFilter = "kind:Music";
    MySearchBox.SetLocalContentSuggestionSettings(settings);
}

Remarks

When local content suggestions are enabled, Windows provides search suggestions from the user's local files as the user enters query text. For example, a picture application can configure local content suggestions so that search suggestions come only from a particular kind of image file that is stored in the user's picture library.

To search a local library, the appropriate capability must be declared in the app manifest. For more info, see App capability declarations.

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Inherited from DependencyObject

StartBringIntoView StartBringIntoView StartBringIntoView

Inherited from UIElement

StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions)

Inherited from UIElement

StartDragAsync(PointerPoint) StartDragAsync(PointerPoint) StartDragAsync(PointerPoint)

Inherited from UIElement

TransformToVisual(UIElement) TransformToVisual(UIElement) TransformToVisual(UIElement)

Inherited from UIElement

TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)

Inherited from UIElement

TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer)

Inherited from UIElement

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Inherited from DependencyObject

UpdateLayout UpdateLayout UpdateLayout

Inherited from UIElement

Events

AccessKeyDisplayDismissed AccessKeyDisplayDismissed AccessKeyDisplayDismissed

Inherited from UIElement

AccessKeyDisplayRequested AccessKeyDisplayRequested AccessKeyDisplayRequested

Inherited from UIElement

AccessKeyInvoked AccessKeyInvoked AccessKeyInvoked

Inherited from UIElement

ActualThemeChanged ActualThemeChanged ActualThemeChanged

Inherited from FrameworkElement

CharacterReceived CharacterReceived CharacterReceived

Inherited from UIElement

ContextCanceled ContextCanceled ContextCanceled

Inherited from UIElement

ContextRequested ContextRequested ContextRequested

Inherited from UIElement

DataContextChanged DataContextChanged DataContextChanged

Inherited from FrameworkElement

DoubleTapped DoubleTapped DoubleTapped

Inherited from UIElement

DragEnter DragEnter DragEnter

Inherited from UIElement

DragLeave DragLeave DragLeave

Inherited from UIElement

DragOver DragOver DragOver

Inherited from UIElement

DragStarting DragStarting DragStarting

Inherited from UIElement

Drop Drop Drop

Inherited from UIElement

DropCompleted DropCompleted DropCompleted

Inherited from UIElement

FocusDisengaged FocusDisengaged FocusDisengaged

Inherited from Control

FocusEngaged FocusEngaged FocusEngaged

Inherited from Control

GettingFocus GettingFocus GettingFocus

Inherited from UIElement

GotFocus GotFocus GotFocus

Inherited from UIElement

Holding Holding Holding

Inherited from UIElement

IsEnabledChanged IsEnabledChanged IsEnabledChanged

Inherited from Control

KeyDown KeyDown KeyDown

Inherited from UIElement

KeyUp KeyUp KeyUp

Inherited from UIElement

LayoutUpdated LayoutUpdated LayoutUpdated

Inherited from FrameworkElement

Loaded Loaded Loaded

Inherited from FrameworkElement

Loading Loading Loading

Inherited from FrameworkElement

LosingFocus LosingFocus LosingFocus

Inherited from UIElement

LostFocus LostFocus LostFocus

Inherited from UIElement

ManipulationCompleted ManipulationCompleted ManipulationCompleted

Inherited from UIElement

ManipulationDelta ManipulationDelta ManipulationDelta

Inherited from UIElement

ManipulationInertiaStarting ManipulationInertiaStarting ManipulationInertiaStarting

Inherited from UIElement

ManipulationStarted ManipulationStarted ManipulationStarted

Inherited from UIElement

ManipulationStarting ManipulationStarting ManipulationStarting

Inherited from UIElement

NoFocusCandidateFound NoFocusCandidateFound NoFocusCandidateFound

Inherited from UIElement

PointerCanceled PointerCanceled PointerCanceled

Inherited from UIElement

PointerCaptureLost PointerCaptureLost PointerCaptureLost

Inherited from UIElement

PointerEntered PointerEntered PointerEntered

Inherited from UIElement

PointerExited PointerExited PointerExited

Inherited from UIElement

PointerMoved PointerMoved PointerMoved

Inherited from UIElement

PointerPressed PointerPressed PointerPressed

Inherited from UIElement

PointerReleased PointerReleased PointerReleased

Inherited from UIElement

PointerWheelChanged PointerWheelChanged PointerWheelChanged

Inherited from UIElement

PrepareForFocusOnKeyboardInput PrepareForFocusOnKeyboardInput PrepareForFocusOnKeyboardInput

Occurs when the FocusOnKeyboardInput property is true and the app receives textual keyboard input.

public : event TypedEventHandler PrepareForFocusOnKeyboardInput<SearchBox, RoutedEventArgs>
public event TypedEventHandler PrepareForFocusOnKeyboardInput<SearchBox, RoutedEventArgs>
Public Event TypedEventHandler PrepareForFocusOnKeyboardInput( Of ( Of SearchBox ), ( Of RoutedEventArgs ))
<SearchBox PrepareForFocusOnKeyboardInput="eventhandler"/>

Remarks

This event occurs only if the FocusOnKeyboardInput property is true. If you wan to provide "type-to-search" behavior in your app, you should handle this event and synchronously ensure the SearchBox control is visible before the event call completes. After this event occurs, the control sets focus to itself.

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.

See Also

PreviewKeyDown PreviewKeyDown PreviewKeyDown

Inherited from UIElement

PreviewKeyUp PreviewKeyUp PreviewKeyUp

Inherited from UIElement

ProcessKeyboardAccelerators ProcessKeyboardAccelerators ProcessKeyboardAccelerators

Inherited from UIElement

QueryChanged QueryChanged QueryChanged

Occurs when the query text changes.

public : event TypedEventHandler QueryChanged<SearchBox, SearchBoxQueryChangedEventArgs>
public event TypedEventHandler QueryChanged<SearchBox, SearchBoxQueryChangedEventArgs>
Public Event TypedEventHandler QueryChanged( Of ( Of SearchBox ), ( Of SearchBoxQueryChangedEventArgs ))
<SearchBox QueryChanged="eventhandler"/>
See Also

QuerySubmitted QuerySubmitted QuerySubmitted

Occurs when the user submits a search query.

public : event TypedEventHandler QuerySubmitted<SearchBox, SearchBoxQuerySubmittedEventArgs>
public event TypedEventHandler QuerySubmitted<SearchBox, SearchBoxQuerySubmittedEventArgs>
Public Event TypedEventHandler QuerySubmitted( Of ( Of SearchBox ), ( Of SearchBoxQuerySubmittedEventArgs ))
<SearchBox QuerySubmitted="eventhandler"/>

Examples

Here's a basic XAML definition for a SearchBox, and an implementation of the QuerySubmitted handler. It calls Frame.Navigate to load a search query result page (not shown) that's named SearchResultsPage1. The this/Me reference in the handlers is the containing page instance, as is typical for on-page input event handling code. You can see similar code as part of Quickstart: Adding search to an app and Enabling users to search for information in your .

<SearchBox x:Name="mySearchBox" 
    FocusOnKeyboardInput="True"
    QuerySubmitted="mySearchBox_QuerySubmitted"
    Height="35"  />
private void mySearchBox_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args)
{
    this.Frame.Navigate(typeof(SearchResultsPage1), args.QueryText);
}
Private Sub mySearchBox_QuerySubmitted(sender As SearchBox, args As SearchBoxQuerySubmittedEventArgs)
    Me.Frame.Navigate(GetType(SearchResultsPage1), args.QueryText)
End Sub

Remarks

Handle this event so that you can get the QueryText value from SearchBoxQuerySubmittedEventArgs, and pass it on as navigation data when you load a search results page to display to the user.

For a complete example of how to handle QuerySubmitted as part of a complete example that also does search suggestions, see SearchBox control sample.

The handler signature for QuerySubmitted uses TypedEventHandler and enforces that the sender parameter be a SearchBox instance, not just Object.

See Also

ResultSuggestionChosen ResultSuggestionChosen ResultSuggestionChosen

Occurs when the user picks a suggested search result.

public : event TypedEventHandler ResultSuggestionChosen<SearchBox, SearchBoxResultSuggestionChosenEventArgs>
public event TypedEventHandler ResultSuggestionChosen<SearchBox, SearchBoxResultSuggestionChosenEventArgs>
Public Event TypedEventHandler ResultSuggestionChosen( Of ( Of SearchBox ), ( Of SearchBoxResultSuggestionChosenEventArgs ))
<SearchBox ResultSuggestionChosen="eventhandler"/>

RightTapped RightTapped RightTapped

Inherited from UIElement

SizeChanged SizeChanged SizeChanged

Inherited from FrameworkElement

SuggestionsRequested SuggestionsRequested SuggestionsRequested

Occurs when the user's query text changes and the app needs to provide new suggestions to display in the search pane.

public : event TypedEventHandler SuggestionsRequested<SearchBox, SearchBoxSuggestionsRequestedEventArgs>
public event TypedEventHandler SuggestionsRequested<SearchBox, SearchBoxSuggestionsRequestedEventArgs>
Public Event TypedEventHandler SuggestionsRequested( Of ( Of SearchBox ), ( Of SearchBoxSuggestionsRequestedEventArgs ))
<SearchBox SuggestionsRequested="eventhandler"/>

Remarks

You can get suggestions from several sources:

  • You can define them yourself. For example, you could create a list of car manufacturers.
  • You can get them from Windows if your app searches local files.
  • You can get them from a web service or server.

For user experience guidelines for displaying suggestions, see Guidelines and checklist for search.

You can use LocalContentSuggestionSettings to add suggestions, based on local files from Windows, in only a few lines of code. Alternatively, you can register for the search box control's SuggestionsRequested event and build your own list of suggestions that is made up of suggestions you retrieved from another source (like a locally-defined list or a web service).

For code examples that show how to add search suggestions, download the SearchBox control sample. The sample demonstrates how to add search suggestions by using all three possible sources, and how to add suggestions for East Asian languages by using alternate forms of the query text generated by an Input Method Editor (IME). (We recommend using query text alternatives if your app will be used by Japanese or Chinese users.)

Types of search suggestions

There are two types of suggestions your app can display: suggestions that help users refine a query (query suggestions), and suggestions that are actual results of a query (result suggestions). You may choose to display either or both types of suggestions.

If you provide query suggestions and the user selects one, your app should respond by displaying results for the selected, refined query in your app's search results page.

If you provide result suggestions, you must also register a ResultSuggestionChosen event handler so that you can respond when the user selects one of your result suggestions and you can display the result to the user.

Displaying app-provided suggestions

After you obtain suggestions, you display them by adding them to the SearchSuggestionsRequest.@Windows.ApplicationModel.Search.SearchSuggestionCollection?text=SearchSuggestionCollection.

If you choose to display both query suggestions and result suggestions, you should group the suggestions by suggestion type (query or result) and separate the groups using AppendSearchSeparator. Each separator takes the place of a suggestion and must be followed by at least one suggestion, decreasing the number of suggestions that you can display.

The maximum length of all of the textual fields in a suggestion (such as text, detail text, and image alt text) is 512 characters.

To learn more about using suggestions to create a good search experience for your users in Guidelines and checklist for search.

Handling the SuggestionsRequested event asynchronously

If you want to respond to the SuggestionsRequested event asynchronously, you must obtain a SearchSuggestionsRequestDeferral object before you edit the suggestion list. Here's an example from Quickstart: Adding search to an app that shows how:

        public async static void SearchBox_SuggestionsRequested(
            SearchBox sender, 
            SearchBoxSuggestionsRequestedEventArgs args)
        {

            // This object lets us edit the SearchSuggestionCollection asynchronously. 
            var deferral = args.Request.GetDeferral();

            try { 

                // Retrieve the system-supplied suggestions.
                var suggestions = args.Request.SearchSuggestionCollection;

                var groups = await SampleDataSource.GetGroupsAsync();
                foreach (var group in groups)
                {
                    var matchingItems = group.Items.Where(
                        item => item.Title.StartsWith(
                            args.QueryText, StringComparison.CurrentCultureIgnoreCase));

                    foreach (var item in matchingItems)
                    {
                        suggestions.AppendQuerySuggestion(item.Title);
                    }
                }

                foreach (string alternative in args.LinguisticDetails.QueryTextAlternatives)
                {
                    if (alternative.StartsWith(
                        args.QueryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestions.AppendQuerySuggestion(alternative); 
                    }
                }
            }
            finally {
                deferral.Complete();
            }

        }
See Also

Tapped Tapped Tapped

Inherited from UIElement

Unloaded Unloaded Unloaded

Inherited from FrameworkElement

See Also