AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

[WPF] All HostConfigs - AdaptiveTextBlock Size Rendering clipped (v4.0.30319)

Open mrbrennonwilliams opened this issue 9 years ago • 5 comments

When setting the size property to extralarge the default render clips the text

image

{ "type": "AdaptiveCard", "version": "1.0", "body": [ { "type": "TextBlock", "size": "extraLarge", "color": "attention", "text": "test", "maxLines": 1 } ] }

mrbrennonwilliams avatar Nov 02 '17 22:11 mrbrennonwilliams

Fixed with dotneterrors branch. Thanks @matthidinger

mrbrennonwilliams avatar Nov 04 '17 21:11 mrbrennonwilliams

Not sure how but this appears to be back. Any textblock with default values creates this render

image

mrbrennonwilliams avatar Nov 06 '17 13:11 mrbrennonwilliams

Can you let me know if this is fixed now?

matthidinger avatar Nov 09 '17 04:11 matthidinger

Unfortunately not. Clipping also appears to be dependent on the elements above and below the textblock. In this image, small and medium almost look ok - but I still see the bottom of characters clipping with some different elements before or after:

image

Paste this rabbit into the visualiser

` { "type": "AdaptiveCard", "version": "1.0", "id": "da1d31aa-5c3f-4870-b6f5-1a2893e54958", "minVersion": "1.0", "fallbackText": "how fast does this render", "speak": "teeesss", "backgroundImage": "", "body": [ { "type": "Container", "id": "bbf6eb12-7441-4462-895f-a7340850d65a", "items": [ { "type": "TextBlock", "id": "881a4f2d-ac24-42c2-9469-791ee18c4635", "size": "small", "text": "The quick brown fox jumped over the lazy dog", "maxLines": 1 }, { "type": "TextBlock", "id": "216acd4a-c8b5-4201-b448-75acbece35b0", "text": "The quick brown fox jumped over the lazy dog", "maxLines": 1 }, { "type": "TextBlock", "id": "c9ead743-df21-4aa8-bc58-39bec94e43b9", "size": "medium", "text": "The quick brown fox jumped over the lazy dog", "maxLines": 1 }, { "type": "TextBlock", "id": "97f386c9-6df2-4d68-9012-01f447da4ee9", "size": "large", "text": "The quick brown fox jumped over the lazy dog", "maxLines": 1 }, { "type": "TextBlock", "id": "b8ccde8c-e93c-49c8-a05b-93507fd54b11", "size": "extraLarge", "text": "The quick brown fox jumped over the lazy dog", "maxLines": 1 } ] } ], "actions": [

]

} `

mrbrennonwilliams avatar Nov 09 '17 19:11 mrbrennonwilliams

@matthidinger

So the problem here is in the way the Textblock renderer is calculating the height of the block.

When the textblock renderer is called, a measure block is being created to look at the number of lines in the block. Unfortunately at the point, the block has not loaded, so it has an ActualHeight value of 0.

When the rendered control loads, the binding is called again, only this time the binding height is a fixed value of 15.96. The reason that is happening is because the FontSize of the measure block stays the same regardless of the FontSize applied to the element.

In order to fix this, add this line to AdaptiveTextBlockRenderer.cs

FontSize = uiTextBlock.FontSize,

@ Line 84

mrbrennonwilliams avatar Nov 09 '17 20:11 mrbrennonwilliams