title: Styling depending on content
body: <p>I'm currently trying to write proper style for item displayed as selected in combobox. The reason I'm doing it is, that I have not much control over how ComboBox display the selected item and - for example - on dark background, the item is still displayed black.</p>
  
  <p>I came with the following solution:</p>
  
  <pre><code>&lt;DataTemplate x:Key="MyItem" DataType="ComboBoxItem"&gt;
      &lt;TextBlock Text="{Binding}" Foreground="White"/&gt;
  &lt;/DataTemplate&gt;
  
  &lt;!-- (...) --&gt;
  
  &lt;Style TargetType="{x:Type ComboBox}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate&gt;
  
              &lt;!-- ... --&gt; 
              &lt;!-- Displaying currently selected item --&gt;
  
                   &lt;ContentPresenter Margin="2" IsHitTestVisible="False" 
                       VerticalAlignment="Center" HorizontalAlignment="Stretch"
                       Name="ContentSite"
                       ContentTemplate="{StaticResource MyItem}"
                       Content="{TemplateBinding ComboBox.SelectionBoxItem}" /&gt;
  
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Now when the simple <code>ComboBoxItem</code> is selected, it is correctly displayed in the ComboBox. On the other hand, if I - for example - display a button with some content, in return I get the text <code>System.Windows.Shapes.Rectangle</code>, what is far from what I want to display.</p>
  
  <p>I would like to use different templates for different data types displayed in the ComboBox - I will be able to customize their appearance. How can I achieve that?</p>
  
  <hr />
  
  <p><b>Edit:</b></p>
  
  <p>To be perfectly clear, I'm talking about selected (=chosen) ComboBox item in this context:</p>
  
  <p><img src="https://i.stack.imgur.com/FZdVc.png" alt="Selected item in combo box"></p>
  
  <p>(not about the selected ComboBox item <em>on the ComboBox's list</em>)</p>