MyPanel.cs
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Windows.Foundation;using Windows.UI.Xaml.Controls;namespace App1{ public class MyPanel : Panel { protected override Size MeasureOverride(Size availableSize) { if (Children.Count > 0) { double yy = 0d; double ww = 0d; foreach (var u in Children) { u.Measure(availableSize); Size dssize = u.DesiredSize; yy += dssize.Height; ww = dssize.Width > ww ? dssize.Width : ww; } return new Size(ww, yy); } return availableSize; } protected override Size ArrangeOverride(Size finalSize) { double y = 0d; foreach (var u in Children) { u.Arrange(new Rect(0d, y, u.DesiredSize.Width, u.DesiredSize.Height)); y += u.DesiredSize.Height; } return finalSize; } }}