title: WPF Binding to Tooltip
body: <p>Not sure whats doing here, but the binding works for the label in the data template but not the tool tip. Any help will be appreciated.</p>
  
  <pre><code>                    &lt;DataTemplate DataType="Label"&gt;
                      &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Left"&gt;
                          &lt;StackPanel.ToolTip&gt;
                              &lt;ToolTip DataContext="{Binding Path=PlacementTarget,
         RelativeSource={x:Static RelativeSource.Self}}"&gt;
                                  &lt;TextBlock Text="{Binding Path=DataContext.Description}" /&gt;
                              &lt;/ToolTip&gt;
                          &lt;/StackPanel.ToolTip&gt;
                          &lt;Image Source="{StaticResource ApplicationInfoS}" 
                                 Margin="0 0 5 0" Stretch="None"
                                 HorizontalAlignment="Left" /&gt;
                          &lt;Label Style="{StaticResource lblTextContent}" 
                                 Padding="5 0 0 0"
                                 Content="{Binding Path=DataContext.Description, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>BTW the DataTemplate is used in Listview. "Description" property exists on the view model bound to the list view.</p>
  
  <p>The message I get in the output window in VS2010 is:</p>
  
  <p>System.Windows.Data Error: 39 : BindingExpression path error: 'Description' property not found on 'object' ''String' (HashCode=-466763399)'. BindingExpression:Path=DataContext.Description; DataItem='StackPanel' (Name=''); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have given up for now. Using the following hack for the time being:</p>
  
  <p>Add a Tag to the StackPanel and Bind "Description" to it</p>
  
  <pre><code>    &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Tag="{Binding Path=DataContext.Description, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"&gt;
  </code></pre>
  
  <p>Bind the ToolTip to the Tag. Yes a hack but it works.</p>
  
  <pre><code>&lt;StackPanel.ToolTip&gt;
    &lt;ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}"&gt;
      &lt;TextBlock Text="{Binding Path=Tag}" /&gt;
    &lt;/ToolTip&gt;
  &lt;/StackPanel.ToolTip&gt;
  </code></pre>
  
  <p>Cheers</p>
  
  <p>Mike</p>