Hi,
in my application WPF, I'm using combobox and I bind the ItemsSource with a collection read from database, I would:
- capitalize the item, how is the better way?
- how to set the width of combobox as the length of the items?
Thanks.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 17, 2015, 12:29 AM EST
Create new collection and add item using foreach. at the adding time use item.ToUpper()
for capitalize.
You can not set the width of combobox as the length of items, because item's length may very every time.
Roberto Salemi154 reputationPosted Feb 17, 2015, 5:44 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 17, 2015, 6:24 AM EST
Roberto Salemi154 reputationPosted Feb 17, 2015, 7:28 AM EST
Roberto Salemi154 reputationPosted Feb 17, 2015, 7:28 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 17, 2015, 9:14 AM EST
In XAML it would be:
Width = "Auto"
Just try it.
Roberto Salemi154 reputationPosted Feb 17, 2015, 11:46 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 18, 2015, 4:58 AM EST
It also states in the MSDN documentation (see Remarks section) that this is how to specify auto-sizing behavior:
https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.width(v=vs.110).aspx