SIGN UP MEMBER LOGIN:    
ARTICLE

Silverlight- AutoCompleteBox Control Example

Posted by Vijai Anand Articles | Silverlight with C# December 06, 2010
In this article we will be seeing how to create Silverlight AutoCompleteBox control.
Reader Level:


In this article we will be seeing how to create Silverlight AutoCompleteBox control.

Xaml:

<sdk:AutoCompleteBox/>

Steps Involved:

Creating a Silverlight Application:

  1. Open Visual Studio 2010.
  2. Go to File => New => Project.
  3. Select Silverlight from the Installed templates and choose the Silverlight Application template.
  4. Enter the Name and choose the location.
  5. Click OK.
  6. In the New Silverlight Application wizard check the "Host the Silverlight Application in a new Web site".
  7. Click OK.

Creating the UI:

Open MainPage.xaml file and replace the code with the following.

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="SilverlightApplication10.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">

    <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" />         
    </Canvas>
</
UserControl>

Open MainPage.xaml.cs file and replace the code with the following.

public MainPage()
        {
            InitializeComponent();
            List<string> names = new List<string>();
            names.Add("Anand");
            names.Add("Arun");
            names.Add("Arjun");
            names.Add("Arul");
            names.Add("Bala");
            names.Add("Balaji");
            names.Add("Barani");
            names.Add("Buji");
            autoComplete.ItemsSource = names;
        }


auto.gif

Login to add your contents and source code to this article
share this article :
post comment
 

i am using a telerik radgrid to display items and if i want to add autocompletebox on one of the column the what is to be written in itemsource?

Posted by iti tyagi May 04, 2011

I have a auto complete box in a child window. when i open the child window i unable to set focus to child window. I tried. but the focus set only once at a first time .. Can you provide the solution.

Posted by dhinesh babu Feb 15, 2011
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Become a Sponsor