我有一个带有TextBlock的网格。我试图在TextBlock上显示工具提示(特别是如果通过CharacterEllipsis修剪块的文本时显示全文),但是当我将鼠标悬停在文本块上时,工具提示不会出现。有什么想法吗?
<DataTemplate x:Key="UnjoinedLampTemplate" DataType="{x:Type devices:DeviceViewModel}">
<Grid Width="133.2"
Margin="0,10,0,10"
Cursor="Hand"
HorizontalAlignment="Center" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Border x:Name="DisplayColor" Grid.Row="0"
Width="70" Height="70"
CornerRadius="100"
Background="#54de61" />
<Image Stretch="Uniform" Grid.Row="0"
Width="70" Height="70"
Source="path_to_component" />
<Border x:Name="textDisplay" Grid.Row="0"
Visibility="Visible"
Background="Black" Opacity=".75"
BorderThickness="1" BorderBrush="White"
CornerRadius="5"
VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="{Binding Label}" Style="{StaticResource DeviceLabelStyle}">
<TextBlock.ToolTip>
<ToolTip>
<TextBlock Text="my tooltip" />
</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
</Border>
</Grid>
<DataTemplate.Triggers>
这是TextBlock中引用的DeviceLabelStyle:
<Style x:Key="DeviceLabelStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="{StaticResource PrimaryFontFamily}" />
<Setter Property="Margin" Value="5,3,5,3" />
<Setter Property="Width" Value="100" />
<Setter Property="Foreground" Value="White" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
</Style>