This is a migrated thread and some comments may be shown as answers.

Selected Item is always the type of item

2 Answers 46 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Hiram
Top achievements
Rank 1
Hiram asked on 16 Apr 2010, 08:25 AM
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 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 16 Apr 2010, 01:07 PM
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.
0
Valeri Hristov
Telerik team
answered on 16 Apr 2010, 01:10 PM
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.
Tags
ComboBox
Asked by
Hiram
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or