Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>ToolTips are not part of the visual tree as they are popup based. So your placement target biding (which uses Visual Tree search) to get the relative ancestor wont work. Why not use ContentHacking instead? This way one hacks into the visual tree from the logical elements such as ContextMenu, Popups, ToolTip etc...</p> <ol> <li><p>Declare a StaticResource which is any FrameworkElement (we need support for data context).</p> <pre><code>&lt;UserControl.Resources ...&gt; &lt;TextBlock x:Key="ProxyElement" DataContext="{Binding}" /&gt; &lt;/UserControl.Resources&gt; </code></pre></li> <li><p>Supply a content control in the Visual Tree and set this static resource "ProxyElement" as its content.</p> <pre><code>&lt;UserControl ...&gt; &lt;Grid ...&gt; &lt;ItemsControl x:Name="MyItemsControl" ItemsTemplate="{StaticResource blahblah}" .../&gt; &lt;ContentControl Content="{StaticResource ProxyElement}" DataContext="{Binding ElementName=MyItemsControl}" Visibility="Collapsed"/&gt; </code></pre></li> </ol> <p>What the above steps have done that "ProxyElement" has been connected to the ItemsControl (which serves as a DataContext) and it is available as a SaticResource to be used anywhere.</p> <ol> <li><p>Now use this StaticResource as a source for any bindings which are failing in your tooltip...</p> <pre><code>&lt;Grid ...&gt; &lt;TextBlock x:Name="ObjectText" ToolTipService.Placement="Left" ToolTip="{StaticResource ItemToolTip}" PlacementTarget="{Binding Source={StaticResource ProxyElement}, Path=DataContext}" ... /&gt; &lt;!-- This sets the target as the items control --&gt; </code></pre></li> </ol> <p>and</p> <pre><code> &lt;ToolTip x:Key="ItemToolTip"&gt; &lt;StackPanel DataContext="{Binding Source={StaticResource ProxyElement}, Path=DataContext.DataContext}"&gt;&lt;!-- sets data context of the items control --&gt; &lt;TextBlock Text="{Binding DisplayName.Name}"/&gt; &lt;TextBlock Text="{Binding Details}" FontStyle="Italic"/&gt; ... &lt;/StackPanel&gt; &lt;/ToolTip&gt; </code></pre> <p>Let me know if this helps...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload