[英]Empty text template for WPF ComboBox?
How would I apply "an empty text" template for WPF ComboBox
? 我将如何为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. 我使用上面的代码显示带有一些消息的
ComboBox
。 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
. 现在,当应用程序启动时,默认情况下未选择任何项目,如果是这样,我想在
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"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.