title: DisplayMemberPath not working for ListBox with custom ListBoxItem control
body: <p>I've configured ListBox to use custom <code>ControlTemplate</code> for it self and custom ControlTemplate for <code>ListBoxItem</code>. Unfortunately such change disables the default behvaiour of <code>DisplayMemberPath</code> property. </p>
  
  <pre><code>// resource dictionary of ListBox control template
  &lt;ControlTemplate  x:Key="CustomListBox" TargetType="ListBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:s="clr-namespace:System;assembly=mscorlib"&gt;
     &lt;Border CornerRadius="3" BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="1,1,1,1" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" Name="Bd" SnapsToDevicePixels="True"&gt;
         &lt;ScrollViewer Padding="{TemplateBinding Control.Padding}" Focusable="False"&gt;
             &lt;ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"  /&gt;
         &lt;/ScrollViewer&gt;
     &lt;/Border&gt;
  &lt;/ControlTemplate&gt;
  //trigger code omitted
  &lt;Style TargetType="ListBox"&gt;
      &lt;Setter Property="Control.Template" Value="{StaticResource CustomListBox}"&gt;&lt;/Setter&gt;
  &lt;/Style&gt;
  
  
  
  
  // resource dictionary of ListBoxItem control template
      &lt;ControlTemplate x:Key="CustomListBoxItem" TargetType="ListBoxItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
          &lt;StackPanel&gt;
              &lt;Border BorderThickness="0" CornerRadius="3" Padding="6 6" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="White" Name="Bd" SnapsToDevicePixels="True"&gt;
                  &lt;ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" /&gt;
              &lt;/Border&gt;
              &lt;Label Height="3"&gt;&lt;/Label&gt;
  
          &lt;/StackPanel&gt;
   &lt;/ControlTemplate&gt;
   // trigger code omitted
   &lt;Style TargetType="ListBoxItem"&gt;
      &lt;Setter Property="Control.Template" Value="{StaticResource CustomListBoxItem}"&gt;&lt;/Setter&gt;
      &lt;Setter Property="ItemsControl.DisplayMemberPath" Value="MatchText"&gt;&lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>XAML</p>
  
  <pre><code>&lt;ListBox x:Name="listBox" DisplayMemberPath="MyCustomText"&gt;
  </code></pre>
  
  <p>The DataContext of <code>listBox</code> is set using code. If I omit setting <code>CustomListBoxItem</code> as the control template, than it works as expected. How do you enable <code>DisplayMemberPath</code> when using custom control templates for <code>ListBox</code> and <code>ListBoxItem</code>?</p>