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 274 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ronny
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?

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

1 Answer, 1 is accepted

Sort by
0
Vladi
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,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ComboBox
Asked by
Ronny
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or