# HG changeset patch # User stevenh7776 # Date 1338474926 -3600 # Node ID 8f94475d3146c80432680f39533b65c5d0cdf263 # Parent 48c389520e5d6b7a136d41c40260d8be44008010 final code diff -r 48c389520e5d -r 8f94475d3146 OverlapStackPanelDemo/OverlapStackPanelDemo/MainPage.xaml --- a/OverlapStackPanelDemo/OverlapStackPanelDemo/MainPage.xaml Thu May 31 14:12:43 2012 +0100 +++ b/OverlapStackPanelDemo/OverlapStackPanelDemo/MainPage.xaml Thu May 31 15:35:26 2012 +0100 @@ -9,8 +9,15 @@ mc:Ignorable="d"> + + + - + @@ -21,7 +28,11 @@ Height="100" Fill="Yellow" /> - + @@ -32,7 +43,11 @@ Height="100" Fill="Silver" /> - + diff -r 48c389520e5d -r 8f94475d3146 OverlapStackPanelDemo/OverlapStackPanelDemo/OverlapStackPanel.cs --- a/OverlapStackPanelDemo/OverlapStackPanelDemo/OverlapStackPanel.cs Thu May 31 14:12:43 2012 +0100 +++ b/OverlapStackPanelDemo/OverlapStackPanelDemo/OverlapStackPanel.cs Thu May 31 15:35:26 2012 +0100 @@ -39,29 +39,24 @@ else availableSize.Width = double.PositiveInfinity; - var totalLeftOffset = LeftOffset; - var totalUpperOffset = UpperOffset; - foreach (UIElement child in Children.Where(child => child != null)) { child.Measure(availableSize); - totalLeftOffset += LeftOffset * childrenResolved; - totalUpperOffset += UpperOffset * childrenResolved; - if (Orientation == Orientation.Vertical) { desiredSize.Width = LeftOffset + Math.Max(desiredSize.Width, child.DesiredSize.Width); - desiredSize.Height += (child.DesiredSize.Height - Overlap); + desiredSize.Height += UpperOffset + child.DesiredSize.Height - Overlap; } else { - desiredSize.Height = totalUpperOffset + Math.Max(desiredSize.Height, child.DesiredSize.Height); - desiredSize.Width += (child.DesiredSize.Width - Overlap); + desiredSize.Height = UpperOffset + Math.Max(desiredSize.Height, child.DesiredSize.Height); + desiredSize.Width += LeftOffset + child.DesiredSize.Width - Overlap; } childrenResolved++; } + // take into account the first item doesn't overlap if (Orientation == Orientation.Vertical) { desiredSize.Height += Overlap; @@ -124,12 +119,8 @@ #region Constructor - public OverlapStackPanel() : base() + public OverlapStackPanel() { - Overlap = 50; - Rotation = 355; - UpperOffset = 10; - LeftOffset = 10; } #endregion diff -r 48c389520e5d -r 8f94475d3146 OverlapStackPanelDemo/packages/repositories.config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OverlapStackPanelDemo/packages/repositories.config Thu May 31 15:35:26 2012 +0100 @@ -0,0 +1,4 @@ + + + + \ No newline at end of file