Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

AutoCompleteBox Control in Silverlight using C#

 by Rohatash Kumar on Nov 18, 2011

Here, we will see how to use AutoCompleteBox Control in Silverlight.
Comments: 0 Views: 736 Printable Version 
AutoComleteBox

In this article we take a TextBox for user input. ComboBox that would allow them to scroll the entire list, as well as filter the list as the user typed in the TextBox. you see your word is being typed automatically based on the character you type. This control that provides this functionality is called an AutoCompleteBox.

AXML code:

<UserControl x:Class="SilverlightApplication14.MainPage"

    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"

    d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Loaded="UserControl_Loaded">

 

    <Canvas Background="AntiqueWhite"

            Height="250"

            Width="250" >

        <TextBlock Canvas.Left="5"

                   Canvas.Top="10"

                   Text="Autocompltete Control"

                   Foreground="Blue"

                   FontFamily="Arial"

                   FontSize="16"

                   Width="130"

                   FontWeight="Bold">

        </TextBlock>

        <TextBlock x:Name="txtName"

                   Canvas.Left="5"

                   Canvas.Top="60"

                   Text="Enter the Name:"

                   Foreground="Black"

                   FontFamily="Arial"

                   FontSize="16"

                   Width="130">

        </TextBlock>

        <sdk:AutoCompleteBox x:Name="autoComplete"

                             Canvas.Top="60"

                             Height="20"

                             Width="100"

                             Canvas.Left="136" SelectionChanged="autoComplete_SelectionChanged" />

    </Canvas>

</UserControl>

Now double click on the form and add the following code.

C# code

public MainPage()

        {

            InitializeComponent();

            List<string> nameList = new List<string>

                   {

                "Rohatash", "Ravi", "Rahul","Rajesh", "Ram", "Raj kumar",

                       "raj", "Catherina Biel", "Christopher Ben",

                       "Dan Gupta", "Diptimaya Patra", "Dhananjay Kumar",

                       "Elizabeth Hurley", "Elisa Cuthbert", "Emma Bunton"

                   };

            autoComplete.ItemsSource = nameList;

        }

 

The below figure defines the AutoCompleteBox when we enter character in the TextBox related search character or string will be display.

 

sl1.gif

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Nevron Gauge for SharePoint
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Developer
Joined: Aug 10, 2010
Education: Masters Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.