Browse Source

Show ellipsis when MaxLines are reached

pull/8471/head
Benedikt Stebner 4 years ago
parent
commit
03b8b2eb5e
  1. 1
      samples/Sandbox/MainWindow.axaml
  2. 5
      src/Avalonia.Base/Media/TextFormatting/TextLayout.cs

1
samples/Sandbox/MainWindow.axaml

@ -1,5 +1,4 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
x:Class="Sandbox.MainWindow">
<TextBlock TextDecorations="Underline" Text="Underline "/>
</Window>

5
src/Avalonia.Base/Media/TextFormatting/TextLayout.cs

@ -479,6 +479,11 @@ namespace Avalonia.Media.TextFormatting
//Fulfill max lines constraint
if (MaxLines > 0 && textLines.Count >= MaxLines)
{
if(textLine.TextLineBreak is TextLineBreak lineBreak && lineBreak.RemainingRuns != null)
{
textLines[textLines.Count - 1] = textLine.Collapse(GetCollapsingProperties(width));
}
break;
}
}

Loading…
Cancel
Save