0

There are nice solutions to the problem with combobox and prompt in WPF, but in my case I have mixed items -- image and text. So for example this solution (copied from https://stackoverflow.com/a/11671997/210342):

<ComboBox Name="MyComboBox"
 IsEditable="True"
 IsReadOnly="True"
 Text="-- Select Team --" />

works fine as for prompt, but it has side effect, that when I select an item, the item in turn is not displayed correctly as selected -- it is presented in list OK, but after selection all combobox shows is System.Windows.Controls.ComboBoxItem.

So how to have a prompt (I don't insist of fixing this approach) and properly displayed mixed items?

Community
  • 1
  • 1
greenoldman
  • 16,895
  • 26
  • 119
  • 185

1 Answers1

0

I solved this in ugly way. I added a grid, put this combobox in the grid with ZIndex=0. I added extra button to the grid with ZIndex=1. This way I get an overlay. Any time users clicks on the button (combo is initially hidden) I open combobox programatically. When users selects anything from dropdown list of the combobox I hide the prompt button.

greenoldman
  • 16,895
  • 26
  • 119
  • 185