Display Tooltip in Center of Screen
Using Grid to display pictures around edge of screen.
<Image Source="...." Grid.Row="0" Grid.Column="0">
<Image.Tooltip>
<TextBlock>Some narrative..</TextBlock>
<TextBox Name="ToolTipText" Grid.Row="开发者_高级运维1" Grid.Column="1" />
On MouseOver I want the tooltip to appear in TextBox, but it aways appears centered over the image.
<Style TargetType="ToolTip">
<Setter Property="PlacementTarget"
Value="{Binding ElementName=ToolTipText, Path=Text} />
<Setter Property="Placement" Value="Center" />
Try this
<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>
This
ToolTipService.PlacementTarget="{Binding ElementName=mainGrid}"
Can be replaced by
ToolTipService.PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid}}}"
精彩评论