protected override Size MeasureOverride(Size constraint) { TextBlock[] tbTime = new TextBlock[] { Time0, Time1, Time2, Time3, Time4 }; TextBlock[] tbVal = new TextBlock[] { Val0, Val1, Val2, Val3, Val4 }; TextBlock[] tbDelta = new TextBlock[] { Delta0, Delta1, Delta2, Delta3, Delta4 }; Size c = new Size(constraint.Width / 5, constraint.Height / 5); Size d = new Size(); for(int i = 0; i < 5; i++) { tbTime[i].Measure(c); tbDelta[i].Measure(c); tbVal[i].Measure(c); d.Height += Math.Max(tbDelta[i].DesiredSize.Height, tbVal[i].DesiredSize.Height); d.Width += tbTime[i].DesiredSize.Width; } d.Height += tbTime.Select(x => x.DesiredSize.Height).Max(); d.Width += tbDelta.Select(x => x.DesiredSize.Width).Max(); d.Width += tbVal.Select(x => x.DesiredSize.Width).Max(); d.Height += 50; d.Width += 50; d.Height = Math.Min(d.Height, constraint.Height); d.Width = Math.Min(d.Width, constraint.Width); return base.MeasureOverride(d); }