Browse Source

Merge pull request #3637 from Gillibald/fixes/TeckBlockConstraintUpdate

Invalidate TextLayout when the available size changes
pull/3638/head
Nikita Tsukanov 6 years ago
committed by GitHub
parent
commit
7489d36f9d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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