Selected Item Not Displayed

2 posts, 0 answers
  1. Don
    Don avatar
    44 posts
    Member since:
    Apr 2009

    Posted 01 Dec 2009 Link to this post

    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> 
     
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 01 Dec 2009 Link to this post

    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.
Back to Top