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)

posted on 2018-02-07 11:45  落寞情缘  阅读(3573)  评论(0编辑  收藏  举报

导航