我试图在SelectedIndex在XAML中为-1时设置WPF组合框的背景颜色。我试图在触发器中设置背景颜色,但我得到一个错误,告诉我我无法在触发器的属性中设置绑定。WPF ComboBoxItem当组合框SelectedIndex为-1时,背景更改
感谢
<ComboBox x:Name="cbFormNameList" ItemsSource="{Binding}" DisplayMemberPath="Name" SelectedValuePath="Name"> <ComboBox.Style> <Style TargetType="{x:Type ComboBoxItem}"> <Style.Triggers> <Trigger Property="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedIndex}" Value="-1"> <Setter Property="Background" Value="#FFFAFFA9"/> </Trigger> </Style.Triggers> </Style> </ComboBox.Style> </ComboBox>
哇,那很容易。谢谢 – sondlerd 2010-12-03 17:07:09