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

Can't set initial value in RadComboBox

2 Answers 99 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Charles Bates
Top achievements
Rank 1
Charles Bates asked on 14 Mar 2010, 01:03 PM
Hello,
I have a RadComboBox declared in xaml:
<input:RadComboBox x:Name="FontFamilyCombo" Width="128" Margin="2,2,1,3"     MouseLeftButtonDown="FontFamilyCombo_MouseLeftButtonDown" SelectionChanged="FontFamilyCombo_SelectionChanged" MouseEnter="FontFamilyCombo_MouseEnter" MouseLeave="FontFamilyCombo_MouseLeave" /> 
 
It is initialized in C#:
TextBlock[] family = new TextBlock[4];  
family[0] = new TextBlock { FontFamily = new FontFamily(TextAttributes.arrFontNames[0]), Text = TextAttributes.arrFontNames[0] };  
family[1] = new TextBlock { FontFamily = new FontFamily(TextAttributes.arrFontNames[1]), Text = TextAttributes.arrFontNames[1] };  
family[2] = new TextBlock { FontFamily = new FontFamily(TextAttributes.arrFontNames[2]), Text = TextAttributes.arrFontNames[2] };  
family[3] = new TextBlock { FontFamily = new FontFamily(TextAttributes.arrFontNames[3]), Text = "Default" };  
 
foreach (TextBlock s in family)  
{  
    FontFamilyCombo.Items.Add(s);  
}  
FontFamilyCombo.SelectedIndex = 1;  
FontFamilyCombo.SelectedItem = family[1];  
 
At runtime, no item is selected in the combo box.
What am I doing wrong?
Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Konstantina
Telerik team
answered on 18 Mar 2010, 03:04 PM
Hi Charles,

Thank you for contacting us.

It seems that there is a problem selecting an item defined like TextBlock from the ComboBox like you described. We will continue to investigate the issue. Meanwhile, I can suggest using the TextBlock as a ItemTemplate of the ComboBox.
Please find the attached project for reference.

If you have further questions please feel free to contact us again.

Best wishes,
Konstantina
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
Charles Bates
Top achievements
Rank 1
answered on 18 Mar 2010, 04:51 PM
Thanks, my ComboBox now works as desired.
Tags
ComboBox
Asked by
Charles Bates
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Charles Bates
Top achievements
Rank 1
Share this question
or