Setting the width of a Silverlight combo box to accommodate its widest item

孤街浪徒 提交于 2019-12-12 18:42:06

问题


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…


回答1:


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



来源:https://stackoverflow.com/questions/1477006/setting-the-width-of-a-silverlight-combo-box-to-accommodate-its-widest-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!