WPF TextBlock 文字超长截断并显示省略符号
<TextBlock x:Name="txtTest" Grid.Column="2" FontSize="9pt" Margin="0 2 0 0 " VerticalAlignment="Center" Foreground="#b9b9b9" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text,ElementName=txtTest}" Text="超长文本" />
TextTrimming="CharacterEllipsis"这个属性,会自动截断文本溢出部分(前提是TextBlock宽度不是auto)