Windows.UI.Xaml.Controls.TextBox.InputScope
February 14, 2023 ยท View on GitHub
-description
Gets or sets the context for input used by this TextBox.
-xaml-syntax
<TextBox InputScope="inputScopeName" .../>
- or -
<TextBox>
<TextBox.InputScope>
<InputScope>
<InputScope.Names>
<InputScopeName NameValue="inputScopeName"/>
</InputScope.Names>
</InputScope>
</TextBox.InputScope>
</TextBox>
-xaml-values
- inputScopeName
- A string that matches one of the named constants of the [InputScopeNameValue](../windows.ui.xaml.input/inputscopenamevalue.md) enumeration, such as NumericPin.
-property-value
The input scope, which provides a hint at the type of text input expected by the control. The default is null.
-remarks
The input scope provides a hint at the type of text input expected by the control. Various elements of the system can respond to the hint provided by the input scope and provide a specialized UI for the input type. For example, the touch keyboard might show a number pad for text input when the control has its InputScope set to Number. See the InputScopeNameValue enumeration for a complete list of input scope values.
The control might also interpret the data being entered differently (typically for East Asian related input scopes). The input scope does not perform any validation, and does not prevent the user from providing any input through a hardware keyboard or other input device.
Other properties that affect the touch keyboard are IsSpellCheckEnabled, IsTextPredictionEnabled, and PreventKeyboardDisplayOnProgrammaticFocus. For more info and examples, see Use input scope to change the touch keyboard.
Note
While this property can hold a collection of InputScopeName values, only the first is used, and the rest are ignored.
-examples
Here's how to set the InputScope in XAML and in code.
<TextBox Header="Telephone Number" InputScope="TelephoneNumber"/>
TextBox phoneNumberTextBox = new TextBox();
phoneNumberTextBox.Header="Telephone Number";
InputScope scope = new InputScope();
InputScopeName scopeName = new InputScopeName();
scopeName.NameValue = InputScopeNameValue.TelephoneNumber;
scope.Names.Add(scopeName);
phoneNumberTextBox.InputScope = scope;
-see-also
IsSpellCheckEnabled, IsTextPredictionEnabled, InputScopeNameValue, Use input scope to change the touch keyboard