Is there a way to set a maximum line count for a WPF WrapPanel? The goal would be to max out at 2 lines and add an ellipses if the content would normally wrap to a 3rd line. The trick is that the content is dynamic and not known at compile time.
Asked
Active
Viewed 74 times
0
-
1That looks more like a FlowDocument than a WrapPanel. – Clemens Jul 22 '19 at 20:05
-
Restructuring as a FlowDocument would be fine, but would yield the same question of knowing the resulting line count so an ellipses could be used. – Bill Tarbell Jul 22 '19 at 20:25
-
Must you use a `WrapPanel`? Why not a `TextBlock`? – Sach Jul 22 '19 at 20:33
-
Textblock with Inline content is fine, but would there be a way to know when the 2nd line ends so an ellipses can be used? – Bill Tarbell Jul 22 '19 at 20:42
1 Answers
0
Use a TextBlock
like this
<TextBlock Text="{StaticResource someText}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Margin="10"/>

Aakanksha
- 329
- 2
- 7
-
This overlooks both key points of the question title - showing images and having a maximum line count. – Bill Tarbell Jul 23 '19 at 20:06
-