Browse Source

Update Measure and Layout if a child of RelativePanel updates it's

position.
pull/10361/head
Tim 4 years ago
parent
commit
9fc9a32f22
  1. 39
      src/Avalonia.Controls/RelativePanel.AttachedProperties.cs

39
src/Avalonia.Controls/RelativePanel.AttachedProperties.cs

@ -1,37 +1,30 @@
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.Threading;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
public partial class RelativePanel public partial class RelativePanel
{ {
private static void OnAlignPropertiesChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
{
if (d is Layoutable layoutable && layoutable.Parent is Layoutable layoutableParent)
{
layoutableParent.InvalidateArrange();
}
}
static RelativePanel() static RelativePanel()
{ {
ClipToBoundsProperty.OverrideDefaultValue<RelativePanel>(true); ClipToBoundsProperty.OverrideDefaultValue<RelativePanel>(true);
AboveProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AffectsParentArrange<RelativePanel>(
AlignBottomWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignLeftWithPanelProperty, AlignLeftWithProperty, LeftOfProperty,
AlignBottomWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignRightWithPanelProperty, AlignRightWithProperty, RightOfProperty,
AlignHorizontalCenterWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignTopWithPanelProperty, AlignTopWithProperty, AboveProperty,
AlignHorizontalCenterWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignBottomWithPanelProperty, AlignBottomWithProperty, BelowProperty,
AlignLeftWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignHorizontalCenterWithPanelProperty, AlignHorizontalCenterWithProperty,
AlignLeftWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignVerticalCenterWithPanelProperty, AlignVerticalCenterWithProperty);
AlignRightWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged);
AlignRightWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AffectsParentMeasure<RelativePanel>(
AlignTopWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignLeftWithPanelProperty, AlignLeftWithProperty, LeftOfProperty,
AlignTopWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignRightWithPanelProperty, AlignRightWithProperty, RightOfProperty,
AlignVerticalCenterWithPanelProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignTopWithPanelProperty, AlignTopWithProperty, AboveProperty,
AlignVerticalCenterWithProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignBottomWithPanelProperty, AlignBottomWithProperty, BelowProperty,
BelowProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignHorizontalCenterWithPanelProperty, AlignHorizontalCenterWithProperty,
LeftOfProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged); AlignVerticalCenterWithPanelProperty, AlignVerticalCenterWithProperty);
RightOfProperty.Changed.AddClassHandler<Layoutable>(OnAlignPropertiesChanged);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save