16
votes

I have a Combobox whose ItemsSource is an ObservableCollection of int values. My combobox itemtemplate consists on an image and a textblock which content is given by 2 converters.

How can I set this 2 bindings? The following code does not compile:

<ComboBox.ItemTemplate>
     <DataTemplate>
          <StackPanel Orientation="Horizontal">
               <Image Source="{Binding, Converter={StaticResource IntToImageConverter}}" Stretch="None" />
               <TextBlock Text="{Binding, Converter={StaticResource IntToStringConverter}}" />
          </StackPanel>
     </DataTemplate>
</ComboBox.ItemTemplate>
1

1 Answers

23
votes

You need to remove the , so:

<ComboBox.ItemTemplate>
     <DataTemplate>
          <StackPanel Orientation="Horizontal">
               <Image Source="{Binding Converter={StaticResource IntToImageConverter}}" Stretch="None" />
               <TextBlock Text="{Binding Converter={StaticResource IntToStringConverter}}" />
          </StackPanel>
     </DataTemplate>
</ComboBox.ItemTemplate>