public override void ParentSizeChanged(Size oldSize, Size newSize) { Point p = Position; if (ParentAttachPoint.IsMiddleX()) { p.X += (Size.Width - oldSize.Width) / 2 - (Size.Width - newSize.Width) / 2; } else if (ParentAttachPoint.IsRight()) { p.X += newSize.Width - oldSize.Width; } if (ParentAttachPoint.IsMiddleY()) { p.Y += (Size.Height - oldSize.Height) / 2 - (Size.Height - newSize.Height) / 2; } else if (ParentAttachPoint.IsBottom()) { p.Y += newSize.Height - oldSize.Height; } Position = p; LastParentSize = newSize; }