Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the maximum character length of AutoCompleteBox C# WPF

I am currently developing a C# WPF application. I am using the AutoCompleteBox control and I want to limit the user to only enter a limited number of characters, i.e. only be able to enter 10 characters in the autocompletebox.

I know on a normal textbox the property MaxLength would be used but this doesn't seem to be available for the AutoCompleteBox.

like image 371
Boardy Avatar asked Dec 21 '22 10:12

Boardy


1 Answers

You have the property TextBoxStyle for the AutoCompleteBox

<toolkit:AutoCompleteBox>
    <toolkit:AutoCompleteBox.TextBoxStyle>
        <Style TargetType="TextBox">
            <Setter Property="MaxLength" Value="10"/>
        </Style>
    </toolkit:AutoCompleteBox.TextBoxStyle>
</toolkit:AutoCompleteBox>
like image 137
Fredrik Hedblad Avatar answered Dec 24 '22 00:12

Fredrik Hedblad