Keith Patrick

I have a combobox whereby I want it ("them", really, as I've got several) to display some grayed-out, italicized text in the combo box if there is no selection (i.e. the app just started), but to show the normal item when one is selected (IE7's search dropdown does this). The catch is that I can't set ComboBox.Text to the value because IsEditable=false, so that value's ignored. I've tried messing with the ItemTemplate, but that doesn't apply to the selected item. The only solution I've found is to manually create the entire combobox's style, but in doing so, I tie that behavior to a particular look (for example, I'd have to hardcode the "Classic" theme (or "Aero" or "Luna") with the display bevavior).

It seems like this kind of styling should be pretty easy, but I'm not seeing an easy solution, but I really, really, really do not want to rebuild an entire combobox look just to get the desired behavior.



Re: Windows Presentation Foundation (WPF) Customizing a ComboBox's SelectionBoxItem when SelectedItem=null

Josh Smith

Kevin Moore's InfoTextBox (part of his bag-o-tricks) does something like what you describe. Perhaps this will help: http://wpf.netfx3.com/files/folders/controls/entry5875.aspx




Re: Windows Presentation Foundation (WPF) Customizing a ComboBox's SelectionBoxItem when SelectedItem=null

Horshu

I found a solution.  Basically, I override the template with one that has another combo inside (grid.rowspan=2) with a hidden textblock over it that gets set to visible when <Trigger PropertyName="ComboBox.SelectedItem" Value="{x:Null}"/>