Skip to content

Represents a control that can be used to display or edit plain text.

public class TextBox : System.Windows.Controls.TextBox, IDataInput

Create TextBox

<hc:TextBox />
var textBox = new TextBox();

Enter text

This example shows how to use the Text property to set the initial text content of a TextBox control:

<hc:TextBox Text="This is the content"/>
textBox.Text = "This is the content";

The generated TextBox is shown below: TextBox

For more examples of TextBox, you can refer to the Document of its base class.

Set title and placeholder text

You can add a Header and a Placeholder to a TextBox to indicate to the user its purpose. To use these two attributes

<hc:TextBox hc:InfoElement.Placeholder="Please enter the content"
               hc:InfoElement.Title="This is the content"/>

Styles

Style
TextBoxPlusBaseStyle
TextBoxPlus.Small

Attributes

PropertyDescription
TextGets or sets the text content of the textbox.

TextType

TextTypeTextTypeTextType
MailNDoubleNumber
ChineseNIntPDouble
CommonNnDoublePInt
DigitsNnIntPhone
DoubleNpDoubleUrl
IntNpInt
Persian Only Custom VersionIranNationalCode Only Custom Version

you can use regex pattern in texttype

NOTE

if you want to use RegexPatter, you should Set TextType to Anything except Common

cs
Using HandyControl.Tools;
<hc:TextBox TextType="Mail" hc:InfoElement.RegexPattern="^[0-9]*(?:\.[0-9]+)?$"/>

Validation

for validation follow instructions:

bind to ValidationRule

cs
<hc:TextBox hc:InfoElement.Placeholder="Please Enter Email" hc:InfoElement.Title="Title" hc:InfoElement.Necessary="True" Margin="0,16,0,0">
    <hc:TextBox.Text>
        <Binding Path="Email1" UpdateSourceTrigger="PropertyChanged">
            <Binding.ValidationRules>
                <hc:RegexRule Type="Mail"/>
            </Binding.ValidationRules>
        </Binding>
    </hc:TextBox.Text>
</hc:TextBox>

Released under the MIT License.