ComboBox AutoWidth?

2 posts, 0 answers
  1. Matthias
    Matthias avatar
    26 posts
    Member since:
    Apr 2011

    Posted 12 Jul 2011 Link to this post

    Hi there!

    Is there are feature which autosizes a combobox due to its content?
    I guess I found something for the dropdown-width, but it would be nice to have something similar for the box itself.

    Best Regards,
  2. Pana
    Pana avatar
    748 posts

    Posted 13 Jul 2011 Link to this post


    The following code shows how the RadComboBox sizes itself to its selected item:

    <Window x:Class="WpfApplication9.MainWindow"
            Title="MainWindow" Height="350" Width="525">
            <Border Width="300" VerticalAlignment="Center" BorderThickness="1" BorderBrush="Black">
                <telerik:RadComboBox HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4">
                    <telerik:RadComboBoxItem Content="Small Item" />
                    <telerik:RadComboBoxItem Content="Really Large Item" />
                    <telerik:RadComboBoxItem Content="The longest one possible" />

    However I believe this is not the autosizing you reffer to. You could always use the MinWidth, MaxWidth and Width of the combo but this is kind of obvious.

    Could you possibly send us a screenshot of your combo and draw us which sizes are not correctly set?

    The ComboBox will not size itself to the sizes within it's drop down because the items in the popup has no visual elements generated prior to the popup opening. Also in virtualizing mode using hundreds of items this would be serious performance hit measuring all of them to determine a RadComboBox width.

    I would recommend you to just set a slightly larger width on the RadComboBox than the average RadComboBoxItem width.

    Best wishes,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
Back to Top