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

2 posts, 0 answers
  1. Ronny
    Ronny avatar
    8 posts
    Member since:
    Mar 2012

    Posted 27 Nov 2012 Link to this post

    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" >
  2. Vladi
    Vladi avatar
    743 posts

    Posted 30 Nov 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top