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

Loading…
Cancel
Save