Ghost1372

everything can be handy

TextBox

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

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

Create TextBox

1
<hc:TextBox />
1
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:

1
<hc:TextBox Text="This is the content"/>
1
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

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

Styles

Style
TextBoxPlusBaseStyle
TextBoxPlus.Small

Attributes

Property Description
Text Gets or sets the text content of the textbox.

TextType

TextType TextType TextType
Mail NDouble Number
Chinese NInt PDouble
Common NnDouble PInt
Digits NnInt Phone
Double NpDouble Url
Int NpInt
Persian Only Custom Version IranNationalCode Only Custom Version

you can use regex pattern in texttype

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

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

Validation

for validation follow instructions:

bind to ValidationRule

1
2
3
4
5
6
7
8
9
<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>
0%