Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Rotated TextBlock - text is cut before rotation
8 replies. Latest Post by Mark Rideout on April 10, 2009.
(0)
VladF
Member
216 points
87 Posts
11-28-2007 7:24 PM |
I created a TextBlock with several words of text. I set a fixed Width for it and applied RotateTransform to it as a render transform. The entire text is longer than the assigned width, but TextBlock is rotated 90 degrees and rotated text should fit pretty well vertically (there is no limitation on height). Unfortunatelly only the first word is shown: I suppose it happened because of an optimization to not display invisible text. The problem is that this check was done before render transform was applied and text was rotated. If I remove the Width limitation the entire text will be visible after rotation.
See the sample XAML:
<Canvas x:Name="parentCanvas"
>
<
</
y_makram
Contributor
6172 points
1,233 Posts
11-29-2007 5:17 AM |
I believe that you are confused here. Applying a 90 degree rotate transform on an object does not mean that the width and height of the object will change. 2D and 3D transforms are generally done by multiplying the coordinates of the object by a special matrix. SO transformations does not change the properties of the affected object. TranslateTransform will not change the left and top properties of the object. ScaleTransform will not change the width and height properties of the object. So if fore example a rectangle with 100 width is scaled by double, its width property will not be 200, it will still be 100, and you will need to perform math calculations to get the actual width.
11-29-2007 11:51 AM |
Did you take a look at the XAML I provided? I'm not talking about the not rotated width, I'm talking about clipped text. I know that render transform won't change the dimenstions - it is a RENDER transfrom after all. But TextBlock makes assumption about how much text should be visible and this assumption seems to be wrong for me in this case.
11-29-2007 12:08 PM |
I am not sure that I understand the bug you are posting. I have tried your XAML code and it is behaving normally to me. You have specified the width of the textblock to 55, and Silverlight trims the text to the specified width. When removing the width property, the text is fully displayed.
Yi-Lun L...
All-Star
25052 points
2,747 Posts
11-30-2007 4:24 AM |
Hello, since you’ve rotated the TextBlock for 90 degrees, its Width will appear to be Height. Try to remove the rotation, you’ll notice the same, only the first word is displayed. This is because you have a Width limit set on the TextBlock, and keeps its default TextWrapping value, which is NoWrap. If you set TextWrapping to Wrap, you’ll probably get the result you want.
12-01-2007 10:42 PM |
Do I understand correctly that clipping of the text is happening before the TextBlock is rotated?
12-02-2007 10:48 AM |
Not sure of the sequence. But rotating the text will not affect the clipping, only width, height wordwrap, clip, and opacitymask properties will affect the textblock clipping.
12-10-2007 2:09 AM |
1) Why 2 posts in this thread were marked as answers? I did not mark them.
2) I don't think there is a clear explanation here. What is happening seems to be an optimization and it does not work very well. Here is another example
When you run project with this XAML you will see that 2 first words are shown and visible text is much wider than its set Width. If you say that Width should clip text why it does not clip it in this case? All this looks like "soft" clipping: TextBlock does not clip words, it clips phrases only. Is it a bug or a feature?
Mark Rid...
2357 points
273 Posts
04-10-2009 8:03 PM |
Silverlight 2 TextBlock will stop processing characters at the next word break if that word break is outside the bounds of the TextBlock's Width. In Silverlight all clipping is off by default. When the layout system was added we added layout enforced clipping. Canvas element does not participate in this layout enforced clipping.
Hope this helps,-markSilverlight Text Program ManagerMicrosoftThis post is provided "as-is"