日期:2014-05-17 浏览次数:21284 次
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="SelectedIndex" Value="-1">
<Setter Property="Background">
<Setter.Value>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<TextBlock Foreground="Gray" Text="- 请选择内容 -"/>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
var defaultItem = new string[] { null };
string[] oldItems = new string[] {"item1", "item2", "item3"};
var newItems = defaultItem.Union(oldItems);
this.comboBox1.ItemsSource = newItems;
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Path=Name}"/>
&nb