title: Using a Converter to select DataTemplate and maintain binding?
body: <p>I am having trouble maintaining bindings after using a Converter to select which DataTemplate to use for my control.</p>
  
  <p>My control binds to a collection of IAppointment, some being type WorkOrderAppointment some DowntimeAppointment.  I would like to define a tooltip based on the type.  The converter is selecting the correct DataTemplate based on the type, but the bindings within WorkOrderToolTipTemplate and DowntimeToolTipTemplate are not working, as if they do not have a datacontext.</p>
  
  <p>Can someone help me understand whats going on, or even maybe a solution?</p>
  
  <p>Abbreviated XAML:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;DataTemplate x:Key="WorkOrderToolTipTemplate"&gt;
          &lt;Grid
              Name="WorkOrderToolTips"
              Width="400"
              HorizontalAlignment="Left"
              VerticalAlignment="Top"
              &gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="130*" /&gt;
                  &lt;ColumnDefinition Width="270*" /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;!-- Tooltip Labels --&gt;
              &lt;TextBlock
                  Grid.Row="0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="Site Name:"
                  /&gt;
              &lt;TextBlock
                  Grid.Row="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="Description:"
                  /&gt;
  
              &lt;!-- Tooltip Values --&gt;
              &lt;TextBlock
                  Grid.Row="0"
                  Grid.Column="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="{Binding Appointment.CalendarItem.SiteName}"
                  TextWrapping="Wrap"
                  /&gt;
  
              &lt;TextBlock
                  Grid.Row="1"
                  Grid.Column="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="{Binding Appointment.CalendarItem.Description}"
                  TextWrapping="Wrap"
                  /&gt;
  
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  
      &lt;DataTemplate x:Key="DowntimeToolTipTemplate"&gt;
          &lt;Grid
              Name="DowntimeToolTips"
              Width="400"
              HorizontalAlignment="Left"
              VerticalAlignment="Top"
              &gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="130*" /&gt;
                  &lt;ColumnDefinition Width="270*" /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
                  &lt;RowDefinition Height="Auto" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;!-- Tooltip Labels --&gt;
              &lt;TextBlock
                  Grid.Row="0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="Site Name:"
                  /&gt;
              &lt;TextBlock
                  Grid.Row="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="Event Classification:"
                  /&gt;
  
              &lt;!-- Tooltip Values --&gt;
              &lt;TextBlock
                  Grid.Row="0"
                  Grid.Column="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="{Binding Appointment.Downtime.PlantName}"
                  TextWrapping="Wrap"
                  /&gt;
              &lt;TextBlock
                  Grid.Row="1"
                  Grid.Column="1"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Text="{Binding Appointment.Downtime.EventClassification}"
                  TextWrapping="Wrap"
                  /&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  
      &lt;converters:ToolTipSelectorConverter x:Key="local_ToolTipSelectorConverter"
          DowntimeDataTemplate="{StaticResource DowntimeToolTipTemplate}" 
          WorkOrderDataTemplate="{StaticResource WorkOrderToolTipTemplate}" /&gt;
  
      &lt;DataTemplate x:Key="AppointmentItemTemplate"&gt;
          &lt;TextBlock
          Style="{Binding Appointment, Converter={StaticResource local_AppointmentTextStyleConverter}}"
          Text="{Binding Appointment.Subject}"
          TextTrimming="WordEllipsis"
          TextWrapping="Wrap"
          &gt;
          &lt;ToolTipService.ToolTip&gt;
              &lt;ToolTip ContentTemplate="{Binding Appointment, Converter={StaticResource local_ToolTipSelectorConverter}}" /&gt;
          &lt;/ToolTipService.ToolTip&gt;
          &lt;/TextBlock&gt;
      &lt;/DataTemplate&gt;
  
  
  &lt;UserControl.Resources&gt;
  </code></pre>