WPF TextBlock 判断 isTextTrimmed 文本是否超出
2017-08-08 10:19
836 查看
WPF TextBlock 设置TextTrimming情况下
判断 isTextTrimmed(Text 文本是否超出 是否出现了省略号)
根据以上属性,可以做很多事,如文本超出时,设置ToolTip、文本替换等。
判断 isTextTrimmed(Text 文本是否超出 是否出现了省略号)
private bool HasTextTrimmed(TextBlock textBlock) { Typeface typeface = new Typeface( textBlock.FontFamily, textBlock.FontStyle, textBlock.FontWeight, textBlock.FontStretch); FormattedText formattedText = new FormattedText( textBlock.Text, System.Threading.Thread.CurrentThread.CurrentCulture, textBlock.FlowDirection, typeface, textBlock.FontSize, textBlock.Foreground); formattedText.MaxTextWidth = textBlock.ActualWidth; bool isTrimmed = formattedText.Height > textBlock.ActualHeight || formattedText.Width >textBlock.MaxTextWidth; return isTrimmed; }
根据以上属性,可以做很多事,如文本超出时,设置ToolTip、文本替换等。
相关文章推荐
- 判断TextView文本内容是否超出一行
- 判断TextView文本内容是否超出一行
- Android判断TextView是否超出加省略号
- Android TextView 判断文字内容是否超出显示省略号
- 设置maxLines=2,ellipseSize=end,判断文本内容是否超出,显示省略号
- TextView的展开收缩功能的实现;(及判断TextView是否超出)
- textview文本超出部分用省略号表示
- jquery判断一个div的边界是否超出另外一个div的边界
- is_a 判断一个对像是否属于一个类,或者该类的父类
- File.exists()判断文件是否存在,File.isDirectory()判断目录是否存在
- 多行文本省略,并且判断是否需要省略。
- PHP - Manual手册 - XL. Filesystem 文件系统函数 - is_uploaded_file判断文件是否是通过 HTTP POST 上传的
- PHP - Manual手册 - XL. Filesystem 文件系统函数 - is_dir判断给定文件名是否是一个目录
- POJ 1308 Is It A Tree?(判断是否是一棵树)
- 使用API判断网络是否连通(InternetGetConnectedState / IsNetworkAlive)
- is(':checked'); 判断radio是否选中,该属性会随着radio被切换点击而变化
- C#/asp.net文本长度判断、判断邮件格式、判断下拉菜单、判断是否为数字
- 丶使用is关键字判断对象是否与指定类型兼容
- 判断富文本是否为空
- iOS开发:==、isEqual与isEqualToString判断是否相等