2013-02-26 3 views
0

ComboBox 클래스를 만들어 명령을 사용할 수있게되었으며 ComboBox의 배경색을 CommandParameter로 보내고 싶습니다. ComboBox의 배경을 SelectedItem의 배경색에 바인딩하고 싶습니다. CommandParameter을 결합하여 전송하는 콤보 스타일 WPF xaml 바인딩 ComboBox 배경색에서 SelectedItem의 색으로

나는
<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의 Background에 바인딩하고 싶습니다.

 <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> 

답변

0

시도 :

<Setter Property="Background" Value="{Binding SelectedItem.Background, RelativeSource={RelativeSource Self}}"/>