Silverlight AutoCompleteBox in VB.NET

Here we will look the use of AutoCompleteBox.
  • 2171

Introduction: AutoCompleteBox provide facility to text entry with drop-down list suggestion of matching items. like, if user type something in it then all matching item will show in drop-down list.
 To work with it, we take a silverlight application. Then we take  a AutoCompleteBox. The XAML code will look like below in editor

   <Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded" Width="400"Height="300">
      <sdk:AutoCompleteBox Height="28" HorizontalAlignment="Left" Margin="10,10,0,0"Name="autoCompleteBox1"

 VerticalAlignment="Top" Width="120"/>       </Grid>

 Then, we create a array or list that will contain all suggestion for AutoCompleBox. we add array or list with AutoCompleBox by its ItemsSource property. The code for this is given below

    AutoCompleteBox1.ItemsSource = months

 Then, we run the application. Here we look that if we press j in AutoCompleteBox then, all matching item like JANUARY,JUNE,JULY appears in drop-down list. like following figure



Now, we set the property IsTextCompletionEnabled to true, by clicking on checkbox. After setting this property, If we press a button then AutoCompleteBox will be filled with remaining text of top item in drop-down list. Means if we press m button, then AutoCompleteBox will be filled with ARCH. like below figure



AutoCompleteBox has FilterMode property which has different values that decides way of filtering items for suggestion in drop-down list. Some more important among those values are below

  • None: No filtering is performed. All the items of the will be appear in the drop-down list when we press any alphanumeric key. like figure 3.



  • StartsWith: Filter is performed with the first entered character. all the matched item is appeared in drop-down list. By default this property is set. like figure 4



  • StartsWithCaseSensitive: Filter is performed on the basis of matching with Capital an small letter. like figure 5



  • Contains: Filter is performed with matching with input text to all items of array or list. only those item will be appeared , to which input text is sub part. like figure 6




More Articles

© 2020 DotNetHeaven. All rights reserved.