Browse Source

Invalidate text layout when the available size changes

pull/3637/head
Benedikt Schroeder 7 years ago
parent
commit
2d5258e118
  1. 11
      src/Avalonia.Controls/TextBlock.cs

11
src/Avalonia.Controls/TextBlock.cs

@ -395,7 +395,7 @@ namespace Avalonia.Controls
/// <summary>
/// Invalidates <see cref="TextLayout"/>.
/// </summary>
protected void InvalidateFormattedText()
protected void InvalidateTextLayout()
{
_textLayout = null;
}
@ -412,6 +412,11 @@ namespace Avalonia.Controls
return new Size();
}
if (_constraint != availableSize)
{
InvalidateTextLayout();
}
_constraint = availableSize;
return TextLayout?.Bounds.Size ?? Size.Empty;
@ -420,13 +425,13 @@ namespace Avalonia.Controls
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnAttachedToLogicalTree(e);
InvalidateFormattedText();
InvalidateTextLayout();
InvalidateMeasure();
}
private void OnTextPropertiesChanged()
{
InvalidateFormattedText();
InvalidateTextLayout();
InvalidateMeasure();
}
}

Loading…
Cancel
Save