<Style x:Key="MyToolTipStyle" TargetType="ToolTip"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Border MaxWidth="600" MinHeight="16" MaxHeight="320" Padding="5,5,5,5" BorderBrush="{DynamicResource Brush_Gray_l6_FFCACACA}" Background="White" BorderThickness="1"> <TextBlock TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{TemplateBinding ContentControl.Content}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
使用如下
<TextBlock Text="{Binding Content}" Grid.Row="0" Height="35" Grid.ColumnSpan="1" TextTrimming="CharacterEllipsis" Margin="0,50,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBlock.ToolTip> <ToolTip Style="{StaticResource MyToolTipStyle}" Content="{Binding Content}" /> </TextBlock.ToolTip> </TextBlock>
时间: 2024-11-05 16:31:25