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

Selected Item Not Displayed

1 Answer 122 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 01 Dec 2009, 03:52 PM
I have a combo box with predefined values and the selected item does not display when the page first comes up. If I select something from the combo box then is displays just fine. Is there something else I need to set? I am using the lates Q3 controls.

        <telerikInput:RadComboBox x:Name="rddNormalRouteLineType" HorizontalAlignment="Right" Margin="0,49,50,0" VerticalAlignment="Top" Width="95" Height="20">  
            <telerikInput:RadComboBoxItem IsSelected="True">  
                <TextBlock Text="Solid" /> 
            </telerikInput:RadComboBoxItem> 
            <telerikInput:RadComboBoxItem> 
                <TextBlock Text="Dashed" /> 
            </telerikInput:RadComboBoxItem> 
            <telerikInput:RadComboBoxItem> 
                <TextBlock Text="Dot" /> 
            </telerikInput:RadComboBoxItem> 
            <telerikInput:RadComboBoxItem> 
                <TextBlock Text="Dash Dot" /> 
            </telerikInput:RadComboBoxItem> 
            <telerikInput:RadComboBoxItem> 
                <TextBlock Text="Dash Dot Dot" /> 
            </telerikInput:RadComboBoxItem> 
        </telerikInput:RadComboBox> 
 

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 01 Dec 2009, 04:30 PM
Hi Don,

RadComboBox uses a WritableBitmap to render the visual elements in its selection box. This is because one visial element cannot be present in two places in the visual tree. Since the items' content is not rendered before the dropdown is open, RadComboBox has nothing to display in the moment when it is displayed for the first time. When the content of the items is not visual element, it is rendered through a ContentPresenter.

To workaround the problem I would recommend using plain string as content of the combobox items:
<telerikInput:RadComboBox>
    <telerikInput:RadComboBoxItem Content="Solid" IsSelected="true" />
    ...
</telerikInput:RadComboBox>

or in case you need to display visuals, place the visuals in the ContentTemplate of the items, instead in their content:
<telerikInput:RadComboBox>
    <telerikInput:RadComboBoxItem IsSelected="True" Content="Solid">
        <telerikInput:RadComboBoxItem.ContentTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding}" />
            </DataTemplate>
        </telerikInput:RadComboBoxItem.ContentTemplate>
    </telerikInput:RadComboBoxItem>
    ...
</telerikInput:RadComboBox>

I hope this helps.

Greetings,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Don
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or