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> /// <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