0

How would I apply "an empty text" template for WPF ComboBox?

<ComboBox 
          ItemsSource="{Binding Messages}"
          DisplayMemberPath="CroppedMessage"
          Name="Messages"
          Width="150" Margin="0,4,4,4">
</ComboBox>

I use the above code to display a ComboBox with a few messages. Now, when the application starts there's no item chosen by default, and if so, I want to display a custom text on the ComboBox. I think I would need some kind of template with a trigger?

Tower
  • 98,741
  • 129
  • 357
  • 507

2 Answers2

3

Try this...

<ComboBox ItemsSource="{Binding Messages}"
          DisplayMemberPath="CroppedMessage"
          Name="Messages"
          Width="150"
          Margin="0,4,4,4"
          IsEditable="True"
          Text="select" />
g t
  • 7,287
  • 7
  • 50
  • 85
CHANDRA
  • 4,778
  • 8
  • 32
  • 51
  • It's nice, but I don't want it to be editable :). Can I have the same behavior except without editing capabilities? – Tower Jun 10 '12 at 13:47
1

Try this

<ComboBox ItemsSource="{Binding Messages}"
          DisplayMemberPath="CroppedMessage"
          Name="Messages"
          Width="150"
          Margin="0,4,4,4"
          IsEditable="True"
          IsReadOnly="True"
          Text="Select"/>
g t
  • 7,287
  • 7
  • 50
  • 85
anon
  • 11
  • 1