Silverlight Telerik RadComboBox Hell

There’s really nothing very *rad* about the thing, is there? ComboBox-Binding can be VERY frustrating. Here’s hoping some poor soul out there finds this in his or her time of need.

Here’s one utilizing a virtual stackPanel to improve performance with large datasets. It also sets the width to avoid the ugly resizing that occurs when the control recalculates its size on the fly. For items that fall off the drop down’s map: a handy tool-tip.

This guy was tricky because you can’t simultaneously use an ItemTemplate (necessary for the tooltip) and the SelectedValuePath property (necessary to display your value).



<DataTemplate x:Name="ownersComboBoxItemTemplate">
    <TextBlock Text="{Binding Path=CompanyName}">
            <ToolTip Content="{Binding Path=CompanyName}" />

<telerik:RadComboBox x:Name="OwnerComboBox" ItemsSource="{Binding Owners}"
                        SelectedValue="{Binding SelectedOwner, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"
                        EmptyText="Select an owner..."
                        Style="{StaticResource RadComboBoxStyle}"
                        ItemTemplate="{StaticResource ownersComboBoxItemTemplate}"
                        ClearSelectionButtonContent="-- No Selection --"
            <VirtualizingStackPanel Width="300" MaxWidth="300" ScrollViewer.HorizontalScrollBarVisibility="Auto" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s