设置Silverlight组合框的宽度以适应其最宽的项目 [英] Setting the width of a Silverlight combo box to accommodate its widest item
问题描述
在Silverlight应用程序中,我有一些带有数据内容的组合框。我如何设置组合框的宽度,以便它可以容纳其最宽的项目?
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?
我创建了一个在WPF工作的黑客,但它不工作Silverlight - 这是不幸的和预期的; ^(
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…
推荐答案
如果你是数据绑定,那么它会被硬编码,然后循环通过测量文本宽度的元素?相当动态(如果笨重)
It would be hardcoded if you databound, then cycled thru the elements measuring the text width? Seems fairly dynamic (if clunky)
这篇关于设置Silverlight组合框的宽度以适应其最宽的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!