XAMLでSelectedIndexが-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