Can't set initial value in RadComboBox

3 posts, 1 answers
  1. Charles Bates
    Charles Bates avatar
    45 posts
    Member since:
    Feb 2010

    Posted 14 Mar 2010 Link to this post

    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.SelectedIndex = 1;  
    FontFamilyCombo.SelectedItem = family[1];  
    At runtime, no item is selected in the combo box.
    What am I doing wrong?

  2. Answer
    Konstantina avatar
    2332 posts

    Posted 18 Mar 2010 Link to this post

    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,
    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. Charles Bates
    Charles Bates avatar
    45 posts
    Member since:
    Feb 2010

    Posted 18 Mar 2010 Link to this post

    Thanks, my ComboBox now works as desired.
Back to Top