How to limit characters in a textbox

Asked

Viewed 2,145 times

0

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

1 answer

0


It’s quite simple:

in Xaml add:

MaxLength="500"

and in code c#:

NomeDoTextBox.MaxLength = 500;

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

public const int TamMaxCaracteres = 500;

NomeDoTextBox.MaxLength = TamMaxCaracteres;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.