Silverlight 文本修剪和换行问题 [英] Silverlight text trimming and wrapping issue

查看:29
本文介绍了Silverlight 文本修剪和换行问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XAML 中有以下布局:

I have the following layout in XAML:

    <StackPanel Height="40">
        <TextBlock TextWrapping="Wrap" TextTrimming="WordEllipsis"  Margin="0,10,0,10"
                               LineHeight="18" FontSize="12">
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce dapibus commodo dui vulputate laoreet. Donec metus purus, consectetur ut sagittis ut, vestibulum id diam. Suspendisse in urna sem. Ut purus arcu, placerat quis tempus cursus, elementum sed sem. Duis condimentum semper tortor, a pulvinar dolor semper sit amet.
        </TextBlock>
    </StackPanel>

所以在我的堆栈面板中有一个文本框.在本例中,我在父堆栈面板中设置了高度,但在我的实际应用程序中,它设置得更高一些.

So inside my stackpanel there is a textbox. In this example I set the height in the parent stackpanel, but in my real application it is set some level higher.

我必须以多行显示文本并使用省略号作为修剪行为.问题是如果我使用上面的 XAML 代码,文本的最后一行会被剪切.我附上了一个截图来说明行为:

I have to display the text in multiline and use ellipsis as trimming behavior. The problem is if I use the XAML code above, the last line of the text gets cut. I've attached a screenshot to illustrate the behavior:

有没有办法解决这个问题?预期的行为是只显示第一行和末尾的省略号.

Is there a way to solve this issue? The expected behavior would be to show only the first line and the ellipsis at the end of it.

推荐答案

嗯,这个问题是我用 StackPanels 造成的.StackPanel 内的内容高度与显示其中的所有内容一样大.但是父StackPanel有高度限制,里面的内容被剪掉了.

Well, the issue caused because of I used StackPanels. The content's height, inside the StackPanel was as big as it should be to display all content in it. However, the parent StackPanel have a height limit, and the content inside got clipped.

我已将我的 StackPanel 替换为 Grid 并修剪 &包装现在就像一个魅力.

I've replaced my StackPanel to a Grid and trimming & wrapping works like a charm now.

这篇关于Silverlight 文本修剪和换行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆