views:

313

answers:

1

In a Silverlight application I have a number of combo boxes with data content. How do I set the width of the combo box so that it can accommodate its widest item?

I have created a hack that works in WPF, but it does not work in Silverlight – which is both unfortunately and expected ;^(

I might be able to create a workaround by measuring the width of the text but that would be a very hard coded implementation so I would like to find another way.

I cannot really believe that this is not a supported scenario, but I have not been able to find an solution. I hope there is something I have missed…

A: 

It would be hardcoded if you databound, then cycled thru the elements measuring the text width? Seems fairly dynamic (if clunky)

JustLoren
The method of measuring the widths of the texts in the elements of the combo box is hardcoded to a specific way of presenting the elements in the combo box. I would much prefer a generic solution which really *should* be not only possible but also pretty *easy* because of the measuring system of Silverlight (and WPF) - it just isn't.