Skip to main content

Microsoft Silverlight

Unanswered Question TextTrimming property for a textboxRSS Feed

(0)

soniadaku
soniadaku

Member

Member

2 points

4 Posts

TextTrimming property for a textbox

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
y_makram

Contributor

Contributor

6172 points

1,233 Posts

Re: TextTrimming property for a textbox

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.

Thanks
Yasser Makram
http://www.silverlightrecipes.com
_____
Dont forget to click "Mark as Answer" on the post that helped you. If your question has not been answered, please post a followup question.

soniadaku
soniadaku

Member

Member

2 points

4 Posts

Re: Re: TextTrimming property for a textbox

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....

y_makram
y_makram

Contributor

Contributor

6172 points

1,233 Posts

Re: Re: TextTrimming property for a textbox

Silverlight does not currently support TextTrimming attribute for TextBlock. Only WPF currently has support for this attribute.

Thanks
Yasser Makram
http://www.silverlightrecipes.com
_____
Dont forget to click "Mark as Answer" on the post that helped you. If your question has not been answered, please post a followup question.

Kimble8650
Kimble8650

Member

Member

7 points

16 Posts

Re: Re: TextTrimming property for a textbox

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
sepnotic

Member

Member

2 points

1 Posts

Re: Re: TextTrimming property for a textbox

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

Kimble8650
Kimble8650

Member

Member

7 points

16 Posts

Re: Re: TextTrimming property for a textbox

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
Foovanadil

Member

Member

10 points

5 Posts

Re: Re: Re: TextTrimming property for a textbox

 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.soman
milind.s...

Member

Member

389 points

72 Posts

Re: TextTrimming property for a textbox

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

Please "Mark as Answer" if this answered your question.

Sr. User Experience Consultant
SpadeWorx Software Services,
Pune, India.

Kimble8650
Kimble8650

Member

Member

7 points

16 Posts

Re: TextTrimming property for a textbox

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.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities