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?
Try this...
<ComboBox ItemsSource="{Binding Messages}"
DisplayMemberPath="CroppedMessage"
Name="Messages"
Width="150"
Margin="0,4,4,4"
IsEditable="True"
Text="select" />
Try this
<ComboBox ItemsSource="{Binding Messages}"
DisplayMemberPath="CroppedMessage"
Name="Messages"
Width="150"
Margin="0,4,4,4"
IsEditable="True"
IsReadOnly="True"
Text="Select"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.