Article Posted: AutoCompleteComboBox for Silverlight

I have posted an article at CodeProject on customization of the Silverlight AutoCompleteBox to be used as a type-ahead ComboBox in LOB applications at CodeProject. The AutoCompleteComboBox can be used in typical Object-to-Object associations (one that we typically encounter when creating associations in Entity Framework) as well as Foreign Key associations (the new association type introduced with Entity Framework 4).

Here’s a sample usage of the control in a typical MVVM scenario:

  • Object to Object Association:

    Example data structure:

    public class SalesOrderDetail
    {
        Product product;
        public Product Product
        {
            get { return product; }
            set { product = value; }
        }
    }
    

    Example control usage:

     <custom:AutoCompleteComboBox
       SelectedItemBinding="{Binding Product, Mode=TwoWay}"
       ItemsSource="{Binding Path=Products, Source={StaticResource ViewModel}}"
     />
    
  • Foreign Key Association:

    Example data structure:

    public class SalesOrderDetail
    {
        int productID;
        public int ProductID
        {
            get { return productID; }
            set { productID = value; }
        }
    }
    

    Example control usage:

     <custom:AutoCompleteComboBox
       SelectedValue="{Binding ProductID, Mode=TwoWay}"
       SelectedValuePath="ProductID"
       ItemsSource="{Binding Path=Products, Source={StaticResource ViewModel}}"
     />
    

To view the implementation details, you can read the full article at :
http://www.codeproject.com/KB/silverlight/AutoComplete_ComboBox.aspx

The source code along with a demo project can be downloaded from the article as well as here (28 KB). Remember to rename the file as zip for extraction.

Advertisements

10 Responses to “Article Posted: AutoCompleteComboBox for Silverlight”

  1. uberVU - social comments Says:

    Social comments and analytics for this post…

    This post was mentioned on Twitter by SilverlightNews: AutoCompleteComboBox for Silverlight – http://snurl.com/ua2i1

  2. Все о Microsoft Silverlight » Автозаполняемый ComboBox для Silverlight Says:

    […] Собственно пример простого автозаполнения. Статья. […]

  3. DotNetShoutout Says:

    AutoCompleteComboBox for Silverlight « Mehroz’s Experiments…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

  4. Jandos Says:

    I have a problem with using AutoCompleteComboBox. In two way binding mode, after setting datacontext to a new domain object instance, autocompletecombobox reverts to previous instance’s value. I have built small app to show this. Where can I upload it? Thank you.

  5. Syed Mehroz Alam Says:

    Jandos,

    You can try uploading your app to skydrive.

  6. Paul Carter Says:

    Hi There,

    I would like to use your control inh a RIA service application. The only problem i am having is that this control somehow shows the display items by calling the binding objects ToString method. The problem with that for me is that RIA services generates my client side code and I can’t inherit from them as they are sealed classes. I would like to know if there is a different way to spoecify the display string for the combobox?

    Thanks
    Paul.

  7. Syed Mehroz Alam Says:

    Hi Paul,

    Although data classes generated by RIA service are sealed but those are marked partial as well. You can add additional functionality to a partial class in a new file as long as you define the same namespace: Have a look here: Partial Classes and Methods

  8. Kanagaraju Says:

    Any updates on the Jandos question & will it enable auto text search?
    I have a problem with using AutoCompleteComboBox. In two way binding mode, after setting datacontext to a new domain object instance, autocompletecombobox reverts to previous instance’s value. TQ.

  9. Kanagaraju Says:

    Any updates on the Jandos question & will it enable auto text search?
    I have a problem with using AutoCompleteComboBox. In two way binding mode, after setting datacontext to a new domain object instance, autocompletecombobox reverts to previous instance’s value. TQ.

  10. nikhil Says:

    I am using the autocompletecombobox in a DataGridTemplateColumn in silverlight 4. When I add a new row dynamically and pre-populate the dropdown, the dropdown is open by default. There are 4 dropdowns in a row , and all of them are in open state. Is there any way to prevent this?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: