2010-11-01 5 views
1

Использование сетки для отображения изображений вокруг края экрана.Отображение подсказки в центре экрана

<Image Source="...." Grid.Row="0" Grid.Column="0"> 
    <Image.Tooltip> 
     <TextBlock>Some narrative..</TextBlock> 

<TextBox Name="ToolTipText" Grid.Row="1" Grid.Column="1" /> 

На MouseOver Я хочу, чтобы подсказка появится в TextBox, но Визитка появляется по центру над изображением.

<Style TargetType="ToolTip"> 
    <Setter Property="PlacementTarget" 
     Value="{Binding ElementName=ToolTipText, Path=Text} /> 
    <Setter Property="Placement" Value="Center" /> 

ответ

1

Попробуйте

<Grid Name="mainGrid"> 
    <Image Source="...." Grid.Row="0" Grid.Column="0" ToolTipService.PlacementTarget="{Binding ElementName=mainGrid}"> 
     <Image.ToolTip> 
      <ToolTip Placement="Center"> 
       <TextBlock>Some narrative..</TextBlock> 
      </ToolTip> 
     </Image.ToolTip> 
    </Image> 
</Grid> 

Это

ToolTipService.PlacementTarget="{Binding ElementName=mainGrid}" 

Может быть заменен

ToolTipService.PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid}}}"