Display data in RadCombobox using silverlight

4 posts, 0 answers
  1. Sankar
    Sankar avatar
    11 posts
    Member since:
    Aug 2008

    Posted 29 Aug 2008 Link to this post

    I am using WCFService to populate data using Linq SQL class to Silverlight application.

    Now I need to display data in to RadCombobox. Kinldy provide the solution
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Aug 2008 Link to this post

    Hi Sankar,

    To populate RadComboBox from a collection, you need to set the control's ItemsSource property. To specify which is the initially selected item in RadComboBox you need to set SelectedIndex or SelectedItem properties. I am not sure that I understand the question correctly, please, let me know if my answer does not provide a solution for your problem. 

    Best wishes,

    Valeri Hristov (Silverlight Team)
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Sankar
    Sankar avatar
    11 posts
    Member since:
    Aug 2008

    Posted 14 Sep 2008 Link to this post

    Kindly let us know how to set Key & Value for the Drop down list similar to ASP.NET
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Sep 2008 Link to this post

    Hello Sankar,

    The Silverlight controls do not provide the ability to set Key/Value for their items. Instead, it the control is databound you could directly access the data item of the selected RadComboBoxItem:

    List<Product> products = new List<Product>();
    products.Add(new Product() { ID = 1, Name = "Product1", Description = "Short description 1" });
    products.Add(new Product() { ID = 2, Name = "Product2", Description = "Short description 2" });
    products.Add(new Product() { ID = 3, Name = "Product3", Description = "Short description 3" });
    // You could populate the products list from a service instead
    // but the code, related to RadComboBox will be the same
    RadComboBox1.ItemsSource = products;
    ...
    private void RadComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        Product selectedProduct = RadComboBox1.SelectedItem as Product;
        //You can access all properties of the actual Product object that is bound to
        // currently selected RadComboBoxItem
        ...
    }

    I hope this helps.

    All the best,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top