Skip to main content
Home Forums Silverlight Design Designing with Silverlight TextTrimming property for a textbox
9 replies. Latest Post by Kimble8650 on July 8, 2009.
(0)
soniadaku
Member
2 points
4 Posts
07-16-2007 12:09 AM |
I have a text box, which should accept text without resizing. When the editting is complete, it should be like a label. I want to use the "TextTrimming" property. Such that the long text should show up with ellipsis (Example -"somefil... ") Any ideas ?? thanks in advance Sonia
y_makram
Contributor
6172 points
1,233 Posts
07-16-2007 12:56 AM |
TextTrimming attribute is not supported in the current release. http://msdn2.microsoft.com/en-us/library/bb188394.aspx the previous link points to the TextBlock reference and as you can see, there is no TextTrimming attribute. Silverlight is still at pre-release state and new features are still expected.
07-16-2007 1:59 AM |
I know that texttrimming property is only for a "text block". But I need to convert my "textblock" to a "textbox" when double clicked or f2 is pressed... when the focus goes off... it becomes a textblock for which the "ellipsis" can be seen....
07-16-2007 6:43 AM |
Silverlight does not currently support TextTrimming attribute for TextBlock. Only WPF currently has support for this attribute.
Kimble8650
7 points
16 Posts
02-23-2009 7:17 AM |
Any news on this one? Has anyone made some kind of workaround for this?
I have used a valueconverter, that puts the three dots after a certain amount of characters, but it is not an elegant solution, and does not work very well...
sepnotic
1 Posts
04-25-2009 3:10 AM |
Kimble8650: Any news on this one? Has anyone made some kind of workaround for this? I have used a valueconverter, that puts the three dots after a certain amount of characters, but it is not an elegant solution, and does not work very well...
Try this: http://msmvps.com/blogs/luisabreu/archive/2007/05/23/adding-ellipsis-to-your-silverlight-textblocks.aspx
04-29-2009 6:20 AM |
I actually found that a while ago, and it worked in simple cases (I made a control that did this by itself). However, i need this functionality in listboxitems, and when I add my textTrimmingControl there, the listbox goes bonkers! The listbox seems to work ok at first, but when you try to scroll, the items won't.
Foovanadil
10 points
5 Posts
07-03-2009 3:09 PM |
I had a need for TextTrimming and couldn't find much so I took a stab at implementing my own solution. I wrote a blog entry explaining the approach: http://www.bradcunningham.net/2009/07/texttrimming-in-silverlight-2.html
It isn't the most elegant and has limitations as noted at the end of blog post but it worked for my situation. Hoepfully it helps
--Brad
milind.s...
389 points
72 Posts
07-08-2009 2:38 AM |
we are checking the length of the string for e.g length 40 and we want to display only 10 characters, then we use substring with 0 to 9 and get only 10 character and then append "..." in it
07-08-2009 2:58 AM |
I actually had a valueconverter, that checked the amount of characters in the string given. This did work to some extent. But since the width should be dynamic, and we weren't using a monospace font, this obviously did not work. The textblocks looked fine some times, and some times they were too big. I also had the kind of implementation, that checks the width, and trims the text accordingly, but this did not work either (I read about a bug in silverlight 2 that allowed only like 250 layout updates or something), and since I need the texttrimming in a listboxitem, in a listbox that can have hundreds of items, this caused some problems. I am starting to feel more and more, that i cannot solve this in silverlight 2 in any kind of elegant way, and should just hope, that this is fixed in silverlight 3.