Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
XamMultiColumnComboEditor Autosize DropDownWidth
posted

Is there a way to auto size drop down widths to be as wide as the sum of the columns? The string data in my columns can vary in length and I would like the drop down width to auto scale with how wide the sum of the columns are. 

Thanks,

Patrick

  • 34430
    Offline posted

    Hello Patrick,

    There currently does not exist functionality to auto-size the drop down according to the sum of the column widths built-in to the XamMultiColumnComboEditor. In order to implement this, I would recommend handling two events on the editor: Loaded and DropDownOpening.

    The columns that exist in the XamMultiColumnComboEditor do not get assigned a width until either a width is explicitly defined or the drop-down opens the first time. The latter is why I would recommend the Loaded event in this case. In this event's handler, I would recommend that you toggle the IsDropDownOpen property of the editor to true and then back to false. This should ensure that the columns get measured.

    In the DropDownOpening event, you can use a Dispatcher.BeginInvoke action and loop through each element in the XamMultiColumnComboEditor.Columns collection, getting a sum of the ActualWidth properties of each of the columns that exist there. Once finished, you can throttle the MinDropDownWidth and MaxDropDownWidth properties of the editor to ensure that the drop-down's width is equal to the width of your columns.

    If you would like to see an auto-size feature developed and included for the XamMultiColumnComboEditor control, I would recommend suggesting a new product idea for this feature. Normally, I would recommend our product ideas site http://ideas.infragistics.com, but unfortunately, this site has expired and we are currently working on a new product ideas site. I imagine there will be an announcement when the new one goes live, and I would recommend you keep an eye out for it and log your idea there, as this will place you in direct communication with our product management teams who plan and prioritize upcoming feature and development based on community feedback.

    I have attached a sample project to demonstrate the workaround mentioned above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XMCCEAutoSizeDropDownCase.zip