2010-11-29 9 views
1

ツールチップリソースの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}}} 
関連する問題