RadAutoCompleteBox dropdown menu resizes as you scroll.

4 posts, 0 answers
  1. Ivo
    Ivo avatar
    48 posts
    Member since:
    Jul 2011

    Posted 15 Nov 2016 Link to this post

    It is possible to set the width of the drop down menu to the width of the widest item in the list?

    Currently when you scroll the drop down menu resizes automatically if DropDownWidth is set to Auto.

  2. Nasko
    Admin
    Nasko avatar
    670 posts

    Posted 17 Nov 2016 Link to this post

    Hello Ivo,

    The observed by you behavior is an expected one. When you open the DropDown only the visible items are loaded into the visual tree. So, when the DropDownWidth is set to Auto it takes the width only of that visible items. When you began to scroll the other items are loaded into the visual tree. Because of that when an item with bigger width is loaded the DropDownWidth changes. 

    What we could suggest you for your concrete scenario is instead of setting it to auto to measure the width of the filtered items and set the biggest one to the DropDownWidth property. For example you could handle the SearchTextChanged event and inside it to find the widest item from the FilteredItems collections and set the DropDownWidth as needed.

    Please, check the attached sample that demonstrates that approach.

    Hope this helps.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. Ivo
    Ivo avatar
    48 posts
    Member since:
    Jul 2011

    Posted 30 Nov 2016 in reply to Nasko Link to this post

    Hi Nasko,

    Thank you very much. This work as expected. The measure doesn't take into account the vertical scrollbar so the longest items are still cut off. Is there a way to reliably measure the width of the scrollbar and include it in the calculation?

  4. Nasko
    Admin
    Nasko avatar
    670 posts

    Posted 30 Nov 2016 Link to this post

    Hello Ivo,

    Please, check the attached sample that demonstrates how to get the Width of the vertical ScrollBar and include it into the measure. Notice that you might need to add some additional pixels in the ActualWidth in order to adjust it as desired.

    Hope this helps.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top