2010-11-29 44 views
1

我應該在tooltip資源的Text屬性的值中寫入什麼內容,以便動態顯示每個文本塊的文本?重複使用多個文本框的工具提示

<StackPanel x:Name="root"> 
    <StackPanel.Resources> 
     <ResourceDictionary> 

      <ToolTip x:Key="tooltiptemplate"> 
       <TextBlock Background="LightBlue" TextTrimming="WordEllipsis" Text="?????"/> 
      </ToolTip> 

     </ResourceDictionary> 
    </StackPanel.Resources> 

    <TextBlock Text="Mickel" ToolTip="{StaticResource tooltiptemplate}"/> 
    <TextBlock Text="Kim" ToolTip="{StaticResource tooltiptemplate}"/> 
    <TextBlock Text="Jenny" ToolTip="{StaticResource tooltiptemplate}"/> 
</StackPanel> 

回答

2
{Binding PlacementTarget.Text, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}