How to limit characters in a textbox

0

How to limit the amount of characters in a Textbox in xaml and via code behind ?

    
asked by anonymous 24.12.2014 / 13:39

1 answer

0

It's quite simple:

in Xaml add:

MaxLength="500"

and in the C # code:

NomeDoTextBox.MaxLength = 500;

If you have many textbox you can create a variable with this value:

public const int TamMaxCaracteres = 500;

NomeDoTextBox.MaxLength = TamMaxCaracteres;
    
24.12.2014 / 13:41