Skip to content

How To : Curanza and TextBox

Brain-Sys Srl edited this page Aug 19, 2015 · 2 revisions

You can bind a RelayCommand when a TextBox content matches a specified regular expression. Optionally, you can pass an object parameter.

In the example, the command RegexCommand is executed when the user insert a digit.

		 curanza:TextBoxHelper.RegexCommand="{Binding RegexCommand}"
		 curanza:TextBoxHelper.RegexExpression="[0-9]"
		 curanza:TextBoxHelper.RegexCommandParameter="parameter 1"/>```

In the example, the command RegexCommand is executed when the user insert three upper-case letters.

```<TextBox Text="insert three upper case letters to execute the command"
		 curanza:TextBoxHelper.RegexCommand="{Binding RegexCommand}"
		 curanza:TextBoxHelper.RegexExpression="[A-Z][A-Z][A-Z]"
		 curanza:TextBoxHelper.RegexCommandParameter="parameter 2"/>```

In the example below, the TextBox has been set to auto-select the text contained when it gets focus.

```<TextBox curanza:TextBoxHelper.AutoSelectAll="True" />```

Clone this wiki locally