Class TextBox
Represents a control that can be used to display single-format, multi-line
text.
Inheritance
System.Object
TextBox
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "ContentElement", Type = typeof(FrameworkElement))]
public class TextBox : Control, IControl, IFrameworkElement, IUIElement, IDependencyObject
Examples
TextBoxName.Text = "Some text";
Constructors
|
Improve this Doc
View Source
TextBox()
Declaration
Fields
|
Improve this Doc
View Source
AcceptsReturnProperty
Identifies the AcceptsReturn dependency property.
Declaration
public static readonly DependencyProperty AcceptsReturnProperty
Field Value
|
Improve this Doc
View Source
AcceptsTabProperty
Identifies the AcceptsReturn dependency property.
Declaration
public static readonly DependencyProperty AcceptsTabProperty
Field Value
|
Improve this Doc
View Source
CaretBrushProperty
Declaration
public static readonly DependencyProperty CaretBrushProperty
Field Value
|
Improve this Doc
View Source
HorizontalScrollBarVisibilityProperty
Identifies the HorizontalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty
Field Value
|
Improve this Doc
View Source
IsReadOnlyProperty
Declaration
public static readonly DependencyProperty IsReadOnlyProperty
Field Value
|
Improve this Doc
View Source
IsSpellCheckEnabledProperty
Declaration
public static readonly DependencyProperty IsSpellCheckEnabledProperty
Field Value
|
Improve this Doc
View Source
LineHeightProperty
Declaration
public static readonly DependencyProperty LineHeightProperty
Field Value
|
Improve this Doc
View Source
MaxLengthProperty
Identifies the MaxLength dependency property.
Declaration
public static readonly DependencyProperty MaxLengthProperty
Field Value
|
Improve this Doc
View Source
PlaceholderTextProperty
Identifies the PlaceholderText dependency property.
Declaration
public static readonly DependencyProperty PlaceholderTextProperty
Field Value
|
Improve this Doc
View Source
SelectionBackgroundProperty
Declaration
[NotImplemented]
public static readonly DependencyProperty SelectionBackgroundProperty
Field Value
|
Improve this Doc
View Source
SelectionForegroundProperty
Declaration
[NotImplemented]
public static readonly DependencyProperty SelectionForegroundProperty
Field Value
|
Improve this Doc
View Source
TextAlignmentProperty
Declaration
public static readonly DependencyProperty TextAlignmentProperty
Field Value
|
Improve this Doc
View Source
TextDecorationsProperty
Identifies the TextDecorations dependency property.
Declaration
public static readonly DependencyProperty TextDecorationsProperty
Field Value
|
Improve this Doc
View Source
TextProperty
Identifies the Text dependency property.
Declaration
public static readonly DependencyProperty TextProperty
Field Value
|
Improve this Doc
View Source
TextWrappingProperty
Declaration
public static readonly DependencyProperty TextWrappingProperty
Field Value
|
Improve this Doc
View Source
VerticalScrollBarVisibilityProperty
Identifies the VerticalScrollBarVisibility dependency property.
Declaration
public static readonly DependencyProperty VerticalScrollBarVisibilityProperty
Field Value
Properties
|
Improve this Doc
View Source
AcceptsReturn
Gets or sets the value that determines whether the text box allows and displays
the newline or return characters.
Declaration
public bool AcceptsReturn { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
AcceptsTab
Gets or sets the value that determines whether pressing tab while the TextBox has the focus will add a tabulation in the text or set the focus to the next element.
True to add a tabulation, false to set the focus to the next element.
Declaration
public bool AcceptsTab { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
BaselineOffset
Gets a value by which each line of text is offset from a baseline.
Declaration
public double BaselineOffset { get; }
Property Value
Type |
Description |
System.Double |
The amount by which each line of text is offset from the baseline, in device
independent pixels. System.Double.NaN indicates that an optimal baseline offset
is automatically calculated from the current font characteristics. The default
is System.Double.NaN.
|
|
Improve this Doc
View Source
CaretBrush
Gets or sets the brush that is used to render the vertical bar that indicates the
insertion point.
Declaration
public Brush CaretBrush { get; set; }
Property Value
Type |
Description |
Brush |
A brush that is used to render the vertical bar that indicates the insertion point.
|
|
Improve this Doc
View Source
HorizontalScrollBarVisibility
Gets or sets a value that indicates whether a horizontal ScrollBar should
be displayed.
Returns a ScrollBarVisibility value that indicates whether a horizontal ScrollBar
should be displayed. The default value is Hidden.
Declaration
public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }
Property Value
|
Improve this Doc
View Source
IsReadOnly
Declaration
public bool IsReadOnly { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsSpellCheckEnabled
Gets or sets a value that specifies whether the TextBox input
interacts with a spell check engine.
Declaration
public bool IsSpellCheckEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
true if the TextBox input interacts with a spell check engine;
otherwise, false. The default is false.
|
|
Improve this Doc
View Source
LineHeight
Gets or sets the height of each line of content.
Declaration
public double LineHeight { get; set; }
Property Value
Type |
Description |
System.Double |
The height of each line in pixels. A value of 0 indicates that
the line height is determined automatically from the current
font characteristics. The default is 0.
|
Exceptions
Type |
Condition |
System.ArgumentException |
LineHeight is set to a non-positive value.
|
|
Improve this Doc
View Source
MaxLength
Gets or sets the value that determines the maximum number of characters allowed
for user input.
Declaration
public int MaxLength { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
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.
Declaration
public string PlaceholderText { get; set; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
SelectedText
Declaration
public string SelectedText { get; set; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
SelectionBackground
Declaration
[NotImplemented]
public Brush SelectionBackground { get; set; }
Property Value
|
Improve this Doc
View Source
SelectionForeground
Declaration
[NotImplemented]
public Brush SelectionForeground { get; set; }
Property Value
|
Improve this Doc
View Source
SelectionLength
Declaration
public int SelectionLength { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
SelectionStart
Declaration
public int SelectionStart { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
Text
Gets or sets the text displayed in the TextBox.
Declaration
public string Text { get; set; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TextAlignment
Gets or sets how the text should be aligned in the text box.
Declaration
public TextAlignment TextAlignment { get; set; }
Property Value
|
Improve this Doc
View Source
TextDecorations
Gets or sets the text decorations (underline, strikethrough...).
Declaration
public TextDecorationCollection TextDecorations { get; set; }
Property Value
|
Improve this Doc
View Source
TextWrapping
Gets or sets how line breaking occurs if a line of text extends beyond the available width of
the text box.
Declaration
public TextWrapping TextWrapping { get; set; }
Property Value
|
Improve this Doc
View Source
VerticalScrollBarVisibility
Gets or sets a value that indicates whether a vertical ScrollBar should be displayed.
Declaration
public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }
Property Value
Methods
|
Improve this Doc
View Source
OnApplyTemplate()
Builds the visual tree for the
TextBox control when a new
template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
|
Improve this Doc
View Source
OnCreateAutomationPeer()
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Overrides
|
Improve this Doc
View Source
OnGotFocus(RoutedEventArgs)
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnKeyDown(KeyEventArgs)
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnLostFocus(RoutedEventArgs)
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnMouseEnter(MouseEventArgs)
Declaration
protected override void OnMouseEnter(MouseEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnMouseLeave(MouseEventArgs)
Declaration
protected override void OnMouseLeave(MouseEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnMouseLeftButtonDown(MouseButtonEventArgs)
Declaration
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnMouseLeftButtonUp(MouseButtonEventArgs)
Declaration
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
OnTextChanged(TextChangedEventArgs)
Raises the TextChanged event
Declaration
protected virtual void OnTextChanged(TextChangedEventArgs eventArgs)
Parameters
|
Improve this Doc
View Source
OnTextInput(TextCompositionEventArgs)
Declaration
protected override void OnTextInput(TextCompositionEventArgs e)
Parameters
Overrides
|
Improve this Doc
View Source
Select(Int32, Int32)
Declaration
public void Select(int start, int length)
Parameters
Type |
Name |
Description |
System.Int32 |
start |
|
System.Int32 |
length |
|
|
Improve this Doc
View Source
SelectAll()
Selects all text in the text box.
Declaration
Events
|
Improve this Doc
View Source
SelectionChanged
Declaration
[NotImplemented]
public event RoutedEventHandler SelectionChanged
Event Type
|
Improve this Doc
View Source
TextChanged
Occurs when the text is changed.
Declaration
public event TextChangedEventHandler TextChanged
Event Type
Extension Methods