文本块的 TextTrimming 属性不起作用
我可以为 TextBlock
找到一个名为 TextTrimming 的属性,但我无法让它工作。 我在主页中有一个文本块,旨在提供预览。当我单击按钮时,如果其中保存了任何注释,我需要显示几个字符。
即使我设置了 TextTrimming 属性,也会显示整个文本。我尝试减小文本块的宽度,但它仍然在整个屏幕上显示文本 strechin
这是 xaml 代码
<TextBlock
Height="27"
HorizontalAlignment="Left"
x:Name="notesPreview"
Text=""
VerticalAlignment="Top"
Width="236"
Foreground="Gray"
Canvas.Left="20"
Canvas.Top="526"
TextTrimming="WordEllipsis"
MinWidth="236" />
我将文本分配给后面代码中的文本块,如下所示
if (m_bufferArrayNotes[i, j] != "")
{
notes = m_bufferArrayNotes[i, j].Substring(0);
}
else
{
notes = "";
}
notesPreview.TextTrimming = TextTrimming.WordEllipsis;
notesPreview.Text = notes;
文本块的大小展开并显示整个文本,并且可以看到同时平移到下一个枢轴项目:(。
有什么方法可以保持实际宽度静态吗?
I can find a property called TextTrimming for TextBlock
, but I can't get it working.
I have a text block in the MainPage, which is intended to give a preview.. When i click a button if there is any notes saved in it, I need to display few characters.
Even when I have set the TextTrimming propery, the whole text is being shown. I tried reducing the width of the textblock but it still displays the text strechin the whole screen
This is the xaml code
<TextBlock
Height="27"
HorizontalAlignment="Left"
x:Name="notesPreview"
Text=""
VerticalAlignment="Top"
Width="236"
Foreground="Gray"
Canvas.Left="20"
Canvas.Top="526"
TextTrimming="WordEllipsis"
MinWidth="236" />
I assign the text to the textblock in the code behind like this
if (m_bufferArrayNotes[i, j] != "")
{
notes = m_bufferArrayNotes[i, j].Substring(0);
}
else
{
notes = "";
}
notesPreview.TextTrimming = TextTrimming.WordEllipsis;
notesPreview.Text = notes;
The size of the textblock expands and displays whole text and can be seen while pannin to the next pivot item :(.
Is there any way to keep the actual width static?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅AppHub 上的此讨论论坛。
他们建议使用此自定义实现来获得对 TextTrimming 的支持。
See this discussion on the AppHub forums.
They suggest using this custom implementation to get support for TextTrimming.