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

How to change ComboBox drop down menu width dynamically with the drop down button width?

1 Answer 284 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Ronny asked on 27 Nov 2012, 12:53 PM
My combobox must stretch horizontally over the complete window width. This accounts for the combobox drop down button and the dropped down menu also! So I set the width of the combobox to "Auto" and bind the ItemsPanelTemplate width to the combobox width.I also use a text trimming data template for the items.

When starting the application, the width of the drop down menu is corresponding to the combobox button width and the text trimming is working, too. Resizing the window during runtime leads to the following behaviour:

1. Resizing window wider -> drop down button and drop down menu resize correctly (they stay fully stretched over the window width)
2. Resizing window smaller -> drop down button resizes correctly, drop down menu doesn't resize smaller than it was initially. So when dragging the window really small, the drop down menu is cut off.

How can I make the drop down menu width change according to the drop down menu button at runtime?

    <DataTemplate x:Key="ComboBoxCustomTemplate">
        <TextBlock Text="{Binding Name}" TextTrimming="WordEllipsis"/>
    <ItemsPanelTemplate x:Key="ComboBoxItemsPanel">
        <VirtualizingStackPanel Orientation="Vertical" x:Name="iptCombo"
                                Width="{Binding ActualWidth, ElementName=radComboBox, Mode=OneWay}" HorizontalAlignment="Stretch" />
<Grid x:Name="ImageView" Margin="5">
    <telerik:RadComboBox x:Name="radComboBox"
                         ItemsSource="{Binding Items}"
                         ItemsPanel="{StaticResource ComboBoxItemsPanel}"
                         ItemTemplate="{StaticResource ComboBoxCustomTemplate}"
                         SelectedIndex="0" >

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 Nov 2012, 08:11 AM
Hi Ronny,

As we see you posted a support ticket with ID:633962 on the same issue and we have replied to you in that thread, could we continue the discussion there?

All the best,
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question