Browse Source

Call InvalidateArrange on Canvas not child control.

pull/484/head
Steven Kirk 10 years ago
parent
commit
7a67889b45
  1. 27
      src/Perspex.Controls/Canvas.cs

27
src/Perspex.Controls/Canvas.cs

@ -3,6 +3,7 @@
using System; using System;
using Perspex.Input; using Perspex.Input;
using Perspex.Layout;
namespace Perspex.Controls namespace Perspex.Controls
{ {
@ -46,7 +47,7 @@ namespace Perspex.Controls
/// </summary> /// </summary>
static Canvas() static Canvas()
{ {
AffectsArrange(LeftProperty, TopProperty, RightProperty, BottomProperty); AffectsCanvasArrange(LeftProperty, TopProperty, RightProperty, BottomProperty);
} }
/// <summary> /// <summary>
@ -204,5 +205,29 @@ namespace Perspex.Controls
return finalSize; return finalSize;
} }
/// <summary>
/// Marks a property on a child as affecting the canvas' arrangement.
/// </summary>
/// <param name="properties">The properties.</param>
private static void AffectsCanvasArrange(params PerspexProperty[] properties)
{
foreach (var property in properties)
{
property.Changed.Subscribe(AffectsCanvasArrangeInvalidate);
}
}
/// <summary>
/// Calls <see cref="Layoutable.InvalidateArrange"/> on the parent of the control whose
/// property changed, if that parent is a canvas.
/// </summary>
/// <param name="e">The event args.</param>
private static void AffectsCanvasArrangeInvalidate(PerspexPropertyChangedEventArgs e)
{
var control = e.Sender as IControl;
var canvas = control?.Parent as Canvas;
canvas?.InvalidateArrange();
}
} }
} }

Loading…
Cancel
Save