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?
See this discussion on the AppHub forums.
They suggest using this custom implementation to get support for TextTrimming.