0
我已經制作了一個ComboBox類來啓用命令,並且我想將ComboBox的背景顏色作爲CommandParameter發送出去。我想將ComboBox的背景綁定到SelectedItem的背景顏色。WPF xaml綁定組合框背景顏色爲SelectedItem的顏色
對於結合併發送CommandParameter組合框樣式我有
<Style x:Key="colorComboBox" TargetType="{x:Type local:ColorComboBox}" BasedOn="{StaticResource AnnotationToolbarComboBox}">
<Setter Property="Background" Value="***SOME BINDING HERE???***"/>
<Setter Property="Command" Value="{Binding ChangeColor, Mode=OneWay}"/>
<Setter Property="CommandParameter" Value="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}, Path=Background}"/>
<Setter Property="CurrentColor" Value="{Binding CurrentColor, Mode=OneWay}"/>
</Style>
和與ComboBoxItems組合框。我想綁定到這些ComboBoxItems的背景。
<local:CommandableComboBox Background="Red">
<ComboBoxItem Width="50" Height="50" Background="Blue"/>
<ComboBoxItem Width="50" Height="50" Background="Green"/>
<ComboBoxItem Width="50" Height="50" Background="Red"/>
</local:CommandableComboBox>