【问题标题】:DataGrid Text auto scrollDataGrid 文本自动滚动
【发布时间】:2012-08-07 23:06:40
【问题描述】:

在DataGrid中,有一个CheckBoxColumn和一个TextColumn,显示文件路径:

|   |                              |
| x |C:\docs\etc\somefile.txt      |
|   |C:\programs\misc\files\2.0\oth|   <- cut off, too long
| x |                              |

如果长字符串滚动到末尾,我希望用户可以看到文件名:

|   |                              |
| x |..misc\files\2.0\otherfile.zip|
|   |                              |

有没有办法做到这一点?谢谢

【问题讨论】:

标签: wpf text datagrid autoscroll


【解决方案1】:

另一种解决方案是在列模板中使用文本块。将 texttrimming 设置为省略号,并将长文本放在 tooltip 属性中。 http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.texttrimming.aspx

如果你真的想像你的例子那样在左边省略号,你可能需要在测量后面做一些代码,见Length of string that will fit in a specific width

【讨论】:

  • 谢谢。最后一个链接有我正在寻找的答案。
猜你喜欢
  • 1970-01-01
  • 2015-01-08
  • 1970-01-01
  • 2012-11-17
  • 2015-08-20
  • 2016-10-06
  • 1970-01-01
  • 2013-06-23
  • 1970-01-01
相关资源
最近更新 更多