开发者

Alternative Content for a Selected ComboBoxItem

开发者 https://www.devze.com 2022-12-10 14:48 出处:网络
I need to place a ComboBox in a place where I have very limited space. Is there any way to show content for the SelectedItem in the ComboBox that is different than the content that is displayed for th

I need to place a ComboBox in a place where I have very limited space. Is there any way to show content for the SelectedItem in the ComboBox that is different than the content that is displayed for the item in the ComboBox's Popup?

As an example, Firefox does this with it's Site Search 开发者_开发百科box in the top right of the browser. When you open the dropdown, the site names are displayed along with their respective logos, but when a site is selected, only the icon is displayed.


UPDATE: Solution found :-)

I found a solution at this site:

http://blogs.windowsclient.net/airborneengineer/archive/2009/06/25/wpf-styles-and-templates-part-ii-combobox-customization.aspx

I just needed to modify the "DisplayImageWithText" DataTemplate to only show the field I want.


Yes, have 2 sets of data and change the display member column of the combobox - according to the position. as long as the value is the same, it will work good, and you'll get 2 displays out of the same combo-box.

0

精彩评论

暂无评论...
验证码 换一张
取 消