How to make long strings can be automatically changed to "..." - Look Canvas From a developer's perspective, Grid
Before WPF, Silverlight has not come out, you want to have this effect the following figure! ?
The default controls are not! Want? They would have to own a carved Control
If the Web, then
it would be even worse! I wrote a bunch of JS
can use the CSS3 text-ellipse
(Note: Thanksgiving Eric reminder, remember to look at but there is no browser support)
Now in WPF, Silverlight outset property built like this
Especially need such a small screen in the Phone
Basically very simple!
As long as the re-election properties in the TextBlock you can see the property TextTrimming
Then choose WordEllipsis and you're done!
But I wonder if someone like me encounter
Like this situation? TextTrimming obviously to set up!
But also why word or run outside?
Width is not set to automatic?
Windows Phone is not without support this property?
Align is not set to the right?
No, no! I have checked this! But with the MSDN say is not the same Orz
The last discussion with Eric, asked about this property has not been used! ?
Eric was very easy to be converted into normal "..."
My heart OS: it really is Senge say this is the character issue?
Then Eric said a critical word! "There is no use Grid"?
After the change from Grid Canvas entire bolt from the blue
Everything is normal! !
----------------------------------------
Why the TextBlock TextTrimming in Canvas and Grid does not have the same effect?
----------------------------------------
Canvas and Grid beginning for me really is no difference
(From the perspective of a developer is concerned)
直到 TextTrimming 这个属性我才直惊觉到差异很大…
每次看在 MSDN、书籍在介绍 Canvas 、Grid 、StackPanel
都是在说对象是怎么排列的之类
面板名称 |
说明 |
---|---|
Canvas |
定义一个区域,您可以在这个区域内依据相对于 Canvas 区域的座标,明确放置子项目。 |
Grid |
定义由数据行和数据列组成的弹性方格区域。 |
StackPanel |
将子项目排列在可为水平或垂直方向的单一行中。 |
实际上真的没有什么感觉!好像跟开发人员没关系
反正画面出来长的一样,剩下的就随便啦!
查了很久总算有一个可以说服我的了!
MSDN 的 Silverlight 配置系统
http://msdn.microsoft.com/zh-tw/library/cc645025(v=vs.95).aspx#LayoutSystem_LayoutSystem
简单来说!
就是 Canvas 是用一种绝对位置当做座标!
即使画面放大、缩小、超出 Canvas 范围 内容 都不会受到任何影响!
而 Grid 则是会依画面变小而改变 Grid 内的控件
也不允许 内容超出 控件范围!
所以才会造成在 Canvas 中
即使设定了 TextTrimming 过长的字符串依然会跑到外面去的情况发生
以后大家就不会分不清楚到底要用那一个了
参考数据
Silverlight 配置系统
http://msdn.microsoft.com/zh-tw/library/cc645025(v=vs.95).aspx#LayoutSystem_LayoutSystem
Grid 类
http://msdn.microsoft.com/zh-tw/library/system.windows.controls.grid(v=vs.95).aspx
Canvas 类
http://msdn.microsoft.com/zh-tw/library/system.windows.controls.canvas(v=vs.95).aspx
Original: Big Box how long a string can be automatically turned into "& hellip;" - Look Canvas From a developer's perspective, Grid