Selected Item is always the type of item

3 posts, 0 answers
  1. Aho
    Aho avatar
    21 posts
    Member since:
    Oct 2009

    Posted 16 Apr 2010 Link to this post

    Hello

    I am filling a the items of the RadComboBox in the code behind.

                foreach (LJSDataSet.LJ_DBRow row in dbNew.LJ_DB.Rows)  
                {  
                    StackPanel pan = new StackPanel();  
                    TextBlock tb1 = new TextBlock();  
                    TextBlock tb2 = new TextBlock();  
     
                    tb1.Width = 130;  
                    tb1.Text = row.DBNAME;  
     
                    tb2.Width = 90;  
                    tb2.Text = row.DBSERV;  
     
                    pan.Orientation = Orientation.Horizontal;  
                    pan.Children.Add(tb1);  
                    pan.Children.Add(tb2);  
     
                    this.comboDB.Items.Add(pan);  
                } 

    When I compile the project, the combobox items are displayed as expected. But the SeletedItem always shows the type name
    System.Windows.Contols.StackPanel.

    How can I avoid this?

    Thank you in advance.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Apr 2010 Link to this post

    Hi,

    I would strongly recommend providing the dbNew.LJ_DB.Rows collection as ItemsSource of RadComboBox and using the ItemTemplate property to specify the look of the combo items. You could find a similar example here:
    http://demos.telerik.com/silverlight/#combobox/databinding

    Regards,
    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Apr 2010 Link to this post

    Oops, wrong link. This is correct:

    http://demos.telerik.com/wpf/?ComboBox/DataBinding

    Greetings,
    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top