This question is locked. New answers and comments are not allowed.
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.
3 Answers, 1 is accepted
0
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
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.
0

Tim
Top achievements
Rank 1
answered on 30 Nov 2016, 08:25 AM
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?
0
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
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.