title: Displaying Image in ComboBox's selected item
body: <p>I have a custom template for my WPF windows ComboBoxes, which display items that inherit from ComboBoxItem that also have an Image property (so that my items can display both text and an image). Both the text and image display as expected in the ComboBox's popup menu for any given item, but I haven't been able to display an image in the currently selected item.</p>
  
  <p>The ContentPresenter within the ComboBox template that displays the currently selected item has its Content property properly bound to {TemplateBinding SelectionBoxItem}, and its ContentTemplate is bound to the following static resource:</p>
  
  <pre><code>    &lt;DataTemplate x:Key="SelectionBoxItemTemplateTextAndImage" DataType="{x:Type SB:SBComboBoxItem}"&gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="20"/&gt;
                  &lt;ColumnDefinition/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Image Source="{Binding Image}"/&gt;
              &lt;TextBlock Grid.Column="1" Text="{Binding}"/&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>SBComboBoxItem is the custom control that inherits from ComboBox and contains an "Image" property properly registered as a DependencyProperty.</p>
  
  <p>I have attempted alternative implementations of that DataTemplate, including using:</p>
  
  <pre><code>{Binding Path=Image, RelativeSource={RelativeSource TemplatedParent}}
  </code></pre>
  
  <p>as the image's source. That didn't work, even though the text still displays when i set the TextBlock's Text property to:</p>
  
  <pre><code>{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}
  </code></pre>
  
  <p>I've played around and found numerous implementations that display the text, but the equivalents never work for the image. I don't understand why this doesn't work, as setting up the popup to display both images and text was a breeze.</p>
  
  <p>Edit: Here's the added functionality to ComboBoxItem to handle the image, in case there's something I did wrong there:</p>
  
  <pre><code>    public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(Image), typeof(SBComboBoxItem));
      public Image Image { get { return (Image)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } }
  </code></pre>
  
  <p>And here is where I have a ComboBox with the items added:</p>
  
  <pre><code>&lt;ComboBox SelectedIndex="1"&gt;
      &lt;SB:SBComboBoxItem Content="Text"&gt;
          &lt;SB:SBComboBoxItem.Image&gt;
              &lt;Image Source="..\Images\Table.png"/&gt;
          &lt;/SB:SBComboBoxItem.Image&gt;
      &lt;/SB:SBComboBoxItem&gt;
      &lt;SB:SBComboBoxItem Content="MoreText"&gt;
          &lt;SB:SBComboBoxItem.Image&gt;
              &lt;Image Source="..\Images\Euclidian.png"/&gt;
          &lt;/SB:SBComboBoxItem.Image&gt;
      &lt;/SB:SBComboBoxItem&gt;
  &lt;/ComboBox&gt;
  </code></pre>