SIGN UP MEMBER LOGIN:    
ARTICLE

Auto Complete Box in Silverlight

Posted by Gomathi Palaniswamy Articles | Silverlight with C# June 16, 2011
The AutoCompleteBox in Silverlight is used to complete the word automatically in a text box.
Reader Level:


The AutoCompleteBox in Silverlight is used to complete the word automatically in a text box.

Xaml page for AutoCompleteBox:

Tools to be used:

AutoCompleteBox, TextBlock :Just drag and place autocomplete box from tool box to source page.
<navigation:Page xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"  x:Class="ControlSamples.Page1"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"                      d:DesignWidth="640" d:DesignHeight="480" Title="Page1 Page">
    <Grid x:Name="LayoutRoot">
<
input:AutoCompleteBox Name="MyAutoComplete" ValueMemberBinding="{Binding Caption}" HorizontalAlignment="Left" VerticalAlignment="Top" Populating="AutoCompleteBox_Populating" MinWidth="50" MaxHeight="500" MinHeight="5"  MaxWidth="500"  Width="250" Height="25" IsTextCompletionEnabled="True" >
            <input:AutoCompleteBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Caption}"></TextBlock>                  
               
</DataTemplate>           
           
</input:AutoCompleteBox.ItemTemplate>
        </input:AutoCompleteBox>

    </Grid>

</navigation:Page>

Used Properties in AutoCompleteBox:

  1. Name: Name of the control.
     

  2. ValueMemberBinding: A field which has to be bound in an AutoCompleteBox.
     

  3. Horizontal Alignment: Aligns the control's left position.
     

  4. Vertical Alignment: Aligns the control's right position.
     

  5. Width: Width of the control
     

  6. Height: Height of the control
     

  7. MinWidth: The control size which is not decreased below this width.
     

  8. MinHeight: The control size which is not decreased below this height.
     

  9. MaxWidth: The control size which is not increased above this width
     

  10. MaxHeight: The control size which is not increased above this height.
     

  11. IsTextCompletedEnabled: here can set text complete enable to true or false
     

  12. Populating: is fired when typeing a letter.

C#:

void c_GetFirstpassYieldSummaryDetailsCompleted(object sender, ControlSamples.ServiceReference1.GetFirstpassYieldSummaryDetailsCompletedEventArgs e)
        {
            MyAutoComplete.ItemsSource = e.Result.FirstpassYieldSummaryindex;
            MyAutoComplete.PopulateComplete();
       }

         private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
        {
            var obj= new ControlSamples.ServiceReference1.Service1Client();
            obj.GetFirstpassYieldSummaryDetailsCompleted += new EventHandler<ControlSamples.ServiceReference1.GetFirstpassYieldSummaryDetailsCompletedEventArgs>(c_GetFirstpassYieldSummaryDetailsCompleted);
            obj.GetFirstpassYieldSummaryDetailsAsync();
        }
 

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Gauge for SharePoint
Become a Sponsor