<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dan Crevier's Blog : pdc2005</title><link>http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx</link><description>Tags: pdc2005</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Layout to layout animations in WCP (part 2)</title><link>http://blogs.msdn.com/dancre/archive/2005/10/03/layout-to-layout-animations-in-wcp-part-2.aspx</link><pubDate>Tue, 04 Oct 2005 06:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:476689</guid><dc:creator>dancre</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/dancre/comments/476689.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=476689</wfw:commentRss><description>&lt;P&gt;This post continues my series on layout to layout animations in WCP (Avalon). In &lt;a href="http://blogs.msdn.com/dancre/archive/2005/10/02/476328.aspx"&gt;part 1&lt;/A&gt;, I showed to create a panel that lays out its children in a grid and allows the child size to be controlled with a slider through data binding. In this post, I'll describe one method to animate the children to their new position.&lt;/P&gt;
&lt;P&gt;Here's the basic approach. When LayoutOverride needs to move a child, it moves the child, but also applies a RenderTransform to the child to translate it back to its original position. It then applies an animation to the transform so that it decays to zero over time. This has the effect of moving the child to its final position over time. This works even if the item is currently being animated.&lt;/P&gt;
&lt;P&gt;In this post, I'll describe the method I showed at PDC. I'll include a couple of alternate approaches in future posts.&lt;/P&gt;
&lt;P&gt;In order to implement this approach, we need to figure out the current location of each child before we arrange it so that we can apply the correct transform. This is a bit easier said than done. There's no easy way to get the current location a child in the same coordinate space as the arguments to Arrange(). If you use child.TranslatePoint(), you can get the upper-left corner of the child, but it takes margins and alignment into account. You could try to take those into account yourslef, but that's a very fragile approach. Instead, what we'll do is keep track of the parameters necessary to compute where we positioned the child on last layout, and then apply the current RenderTransform. With the layout algorithm used for TilePanel, we just have to keep track of the child size and children per row to calculate where we put any child.&lt;/P&gt;
&lt;P&gt;Here are the modifications to TilePanel. The new code is in bold. I didn't include the methods that did not change.&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#008000&gt;// Arrange the children&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt; ArrangeOverride(&lt;FONT color=#008080&gt;Size&lt;/FONT&gt; finalSize)
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Calculate how many children fit on each row&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; childrenPerRow = &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Max(1, (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;) &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Floor(finalSize.Width / &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize));

&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; i = 0; i &amp;lt; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children.Count; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIElement&lt;/FONT&gt; child = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children[i];

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Figure out where the child goes&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Point&lt;/FONT&gt; newOffset = CalcChildOffset(i, childrenPerRow, &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize);

&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt; (_oldChildrenPerRow != -1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Figure out where the child is now&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Point&lt;/FONT&gt; oldOffset = CalcChildOffset(i, _oldChildrenPerRow, _oldChildSize);
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt; (child.RenderTransform != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;child.RenderTransform.TransformPoint(oldOffset, &lt;FONT color=#0000ff&gt;out&lt;/FONT&gt; oldOffset);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Transform the child from the new location back to the old position&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TranslateTransform&lt;/FONT&gt; childTransform = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;TranslateTransform&lt;/FONT&gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;child.RenderTransform = childTransform;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Decay the transformation with an animation&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;childTransform.BeginAnimation(&lt;FONT color=#008080&gt;TranslateTransform&lt;/FONT&gt;.XProperty, MakeAnimation(oldOffset.X - newOffset.X));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;childTransform.BeginAnimation(&lt;FONT color=#008080&gt;TranslateTransform&lt;/FONT&gt;.YProperty, MakeAnimation(oldOffset.Y - newOffset.Y));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/STRONG&gt;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Position the child and set its size&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;child.Arrange(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Rect&lt;/FONT&gt;(newOffset, &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize, &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize))); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_oldChildrenPerRow = childrenPerRow;
&amp;nbsp;&amp;nbsp;&amp;nbsp;_oldChildSize = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize;&lt;/STRONG&gt;

&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; finalSize;
}

&lt;STRONG&gt;&lt;FONT color=#008000&gt;// Create an animation to decay from start to 0 over .5 seconds&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;DoubleAnimation&lt;/FONT&gt; MakeAnimation(&lt;FONT color=#0000ff&gt;double&lt;/FONT&gt; start)
{
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DoubleAnimation&lt;/FONT&gt; animation = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;DoubleAnimation&lt;/FONT&gt;(start, 0d, &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Duration&lt;/FONT&gt;(&lt;FONT color=#008080&gt;TimeSpan&lt;/FONT&gt;.FromMilliseconds(500)));
&amp;nbsp;&amp;nbsp;&amp;nbsp;animation.AccelerationRatio = 0.2;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; animation;
}

&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;double&lt;/FONT&gt; _oldChildSize = 1d;
&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; _oldChildrenPerRow = -1;&lt;/STRONG&gt;
&lt;/PRE&gt;
&lt;P&gt;The changes end up being pretty simple. _oldChildSize and _oldChildrenPerRow are used to cache the old layout parameters, and then it's a pretty simple matter to calculate the current child positions. Then, we apply the transform to this.&lt;/P&gt;
&lt;P&gt;This method is not incredibly general. We're taking advantage of the fact that it's easy to calculate the positions of the children based on just a couple of parameters. You also can't apply it to an existing layout. I'll talk about some alternate approaches soon.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=476689" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/PanelLayoutAnimator/default.aspx">PanelLayoutAnimator</category></item><item><title>Layout to layout animations in WCP (part 1)</title><link>http://blogs.msdn.com/dancre/archive/2005/10/02/layout-to-layout-animations-in-wcp-part-1.aspx</link><pubDate>Mon, 03 Oct 2005 07:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:476328</guid><dc:creator>dancre</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/dancre/comments/476328.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=476328</wfw:commentRss><description>&lt;P&gt;At PDC, I showed a simple version of layout to layout animations, as we do in &lt;A href="http://microsoft.com/max/"&gt;Microsoft Max&lt;/A&gt;.In Max, when you resize the window or change the size of the items being viewed, they animate to their new locations. This not only looks cool, but really helps usability by letting the user see what's happening to the data being viewed. I will be doing a series of posts showing how this can be done, with a couple of alternatives.&lt;/P&gt;
&lt;P&gt;First, let's start with a non-animating version. I'll base my example on the Avalon Application template (what you get when you do a new Avalon application project from Visual Studio).&lt;/P&gt;
&lt;P&gt;Our first step is to create the Panel we'll be using. The Panel class is used to contain child elements and controls their layout. Built in examples include DockPanel, StackPanel, WrapPanel, and Grid. Like Max, we'll use a simple panel that lays out the children in a grid and lets the child size be controlled by the user. A Panel implementation needs to implement two methods for the two pass arrangement (first measure, then arrange). MeasureOverride figures out the size of the panel based on the current constraints, and is responsible for calling Measure on all children. ArrangeOverride does the work to actually position and size the elements. To allow the child size to be controlled by the UI, we'll set it using a dependency property that the UI can bind to. The panel definition is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; &lt;FONT color=#008080&gt;TilePanel&lt;/FONT&gt; : &lt;FONT color=#008080&gt;Panel&lt;/FONT&gt;
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Dependency property that controls the size of the child elements&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;readonly&lt;/FONT&gt; &lt;FONT color=#008080&gt;DependencyProperty&lt;/FONT&gt; ChildSizeProperty
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= &lt;FONT color=#008080&gt;DependencyProperty&lt;/FONT&gt;.RegisterAttached(&lt;FONT color=#800000&gt;"ChildSize"&lt;/FONT&gt;, &lt;FONT color=#0000ff&gt;typeof&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;double&lt;/FONT&gt;), &lt;FONT color=#0000ff&gt;typeof&lt;/FONT&gt;(&lt;FONT color=#008080&gt;TilePanel&lt;/FONT&gt;),
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;FrameworkPropertyMetadata&lt;/FONT&gt;(1.0d, &lt;FONT color=#008080&gt;FrameworkPropertyMetadataOptions&lt;/FONT&gt;.AffectsMeasure |
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FrameworkPropertyMetadataOptions&lt;/FONT&gt;.AffectsArrange));

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Accessor for the child size dependency property&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;double&lt;/FONT&gt; ChildSize
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;/FONT&gt; { &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;double&lt;/FONT&gt;)GetValue(ChildSizeProperty); }
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set&lt;/FONT&gt; { SetValue(ChildSizeProperty, &lt;FONT color=#0000ff&gt;value&lt;/FONT&gt;); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Measures the children&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt; MeasureOverride(&lt;FONT color=#008080&gt;Size&lt;/FONT&gt; availableSize)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; childrenPerRow;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Figure out how many children fit on each row&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt; (availableSize.Width == &lt;FONT color=#008080&gt;Double&lt;/FONT&gt;.PositiveInfinity)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;childrenPerRow = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children.Count;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;childrenPerRow = &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Max(1, (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;) &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Floor(availableSize.Width / &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize));

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Call measure on all children&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Size&lt;/FONT&gt; childSize = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize, &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize);
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;UIElement&lt;/FONT&gt; child &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;child.Measure(childSize);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Calculate the width and height this results in&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double&lt;/FONT&gt; width = childrenPerRow * &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double&lt;/FONT&gt; height = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize * (&lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Floor((&lt;FONT color=#0000ff&gt;double&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children.Count / childrenPerRow) + 1);
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt;(width, height);
&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Arrange the children&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt; ArrangeOverride(&lt;FONT color=#008080&gt;Size&lt;/FONT&gt; finalSize)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Calculate how many children fit on each row&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; childrenPerRow = &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Max(1, (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;) &lt;FONT color=#008080&gt;Math&lt;/FONT&gt;.Floor(finalSize.Width / &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize));
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; i = 0; i &amp;lt; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children.Count; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIElement&lt;/FONT&gt; child = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.Children[i];

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Figure out where the child goes&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Point&lt;/FONT&gt; newOffset = CalcChildOffset(i, childrenPerRow, &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize);

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Position the child and set its size&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;child.Arrange(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Rect&lt;/FONT&gt;(newOffset, &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Size&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize, &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.ChildSize))); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; finalSize;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Given a child index, child size and children per row, figure out where the child goes&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&lt;/FONT&gt; &lt;FONT color=#008080&gt;Point&lt;/FONT&gt; CalcChildOffset(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; index, &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; childrenPerRow, &lt;FONT color=#0000ff&gt;double&lt;/FONT&gt; childSize)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; row = index / childrenPerRow;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; column = index % childrenPerRow;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Point&lt;/FONT&gt;(column * childSize, row * childSize);
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
&lt;/PRE&gt;
&lt;P&gt;Put this class in the application's namspace. Now, we'll use the panel in a simple window for the app. Here's the&amp;nbsp;contents of Window1.xaml:&lt;/P&gt;&lt;FONT color=#0000ff&gt;&lt;PRE&gt;&amp;lt;?&lt;/FONT&gt;&lt;FONT color=#800000&gt;Mapping&lt;/FONT&gt;&lt;FONT color=#808080&gt; XmlNamespace="MyApp" ClrNamespace="AvalonApplication1" &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;?&amp;gt;
&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;AvalonApplication1.Window1&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/winfx/avalon/2005&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/winfx/xaml/2005&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:myapp&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;MyApp&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; 
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Title&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;AvalonApplication1&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Height&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;300&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Width&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;300&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Orientation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Vertical&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Slider&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;MinWidth&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;200&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Minimum&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;50&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Maximum&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;300&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;
&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SmallChange&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;40&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;_slider&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;myapp:TilePanel &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;ChildSize&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;{Binding ElementName=_slider, Path=Value}&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Red&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Green&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Blue&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Red&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Green&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Blue&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Red&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Green&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Blue&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Red&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Green&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Blue&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;myapp:TilePanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;
&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;If your application has a different namespace than "AvalonApplication1", just replace all instances with your name. The mapping at the top of the file brings in the CLR namespace, and then the xmlns:myapp line maps it into the XML namespace. This lets us use &amp;lt;myapp:TilePanel&amp;gt; element to use our new TilePanel class, and we put a bunch of colored boxes in it. Note that the child size is bound to a slider. The slider and TilePanel are in a StackPanel, so they stack up vertically. The resulting window looks like:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.boingo.org/images/Layout.Png"&gt; &lt;/P&gt;
&lt;P&gt;As you resize the window, the panel's MeasureOverride and ArrangeOverride functions will be called with the new size and the boxes inside will instantly move to their new positions. When you change the slider, it will change the ChildSize property. Since this property is set to affect measure and arrange, it will also call MeasureOverride and ArrangeOverride. This will resize the child elements appropriately.&lt;/P&gt;
&lt;P&gt;In the next post, I'll explain how to make the children animate to their new locations instead of just instantly appear there. I'll go through a few different approaches on doing this.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=476328" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/PanelLayoutAnimator/default.aspx">PanelLayoutAnimator</category></item><item><title>Feedback on Max</title><link>http://blogs.msdn.com/dancre/archive/2005/09/13/feedback-on-max.aspx</link><pubDate>Tue, 13 Sep 2005 23:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:465035</guid><dc:creator>dancre</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/dancre/comments/465035.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=465035</wfw:commentRss><description>&lt;P&gt;It's great seeing feedback on Max - we really want to hear what you think works well, and what doesn't. The best place to send feedback is on our blog at &lt;a href="http://blogs.msdn.com/max/"&gt;http://blogs.msdn.com/max/&lt;/A&gt;. There's also some good feedback at &lt;A href="http://www.neowin.net/comments.php?id=30384&amp;amp;category=main"&gt;http://www.neowin.net/comments.php?id=30384&amp;amp;category=main&lt;/A&gt;&amp;nbsp;and &lt;A href="http://channel9.msdn.com/ShowPost.aspx?PostID=114722"&gt;http://channel9.msdn.com/ShowPost.aspx?PostID=114722&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=465035" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/Max/default.aspx">Max</category></item><item><title>PDC talk on how Max works</title><link>http://blogs.msdn.com/dancre/archive/2005/09/13/pdc-talk-on-how-max-works.aspx</link><pubDate>Tue, 13 Sep 2005 23:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:465019</guid><dc:creator>dancre</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dancre/comments/465019.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=465019</wfw:commentRss><description>&lt;P&gt;On Thursday, Walter Smith and I will be giving a presentation at the PDC about how our team built Max. It's at 1pm in Hall C/D. There will also be members of our team at the presentation lounges in the "big room". Come find us!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=465019" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/Max/default.aspx">Max</category></item><item><title>Max now available!</title><link>http://blogs.msdn.com/dancre/archive/2005/09/13/max-now-available.aspx</link><pubDate>Tue, 13 Sep 2005 21:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:464946</guid><dc:creator>dancre</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dancre/comments/464946.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=464946</wfw:commentRss><description>The cat's out of the bag. Hillel just showed us on stage. Check out &lt;A href="http://www.microsoft.com/max"&gt;http://www.microsoft.com/max&lt;/A&gt;.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=464946" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/Max/default.aspx">Max</category></item><item><title>Backstage at the PDC keynote</title><link>http://blogs.msdn.com/dancre/archive/2005/09/13/backstage-at-the-pdc-keynote.aspx</link><pubDate>Tue, 13 Sep 2005 20:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:464873</guid><dc:creator>dancre</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dancre/comments/464873.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=464873</wfw:commentRss><description>Lots of exciting stuff being announced today, and &lt;A href="http://www.prrrl.com/"&gt;Hillel&lt;/A&gt; will be talking about what I've been working on soon. Stay tuned!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=464873" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category><category domain="http://blogs.msdn.com/dancre/archive/tags/Max/default.aspx">Max</category></item><item><title>I'm speaking at PDC 2005!</title><link>http://blogs.msdn.com/dancre/archive/2005/09/11/463641.aspx</link><pubDate>Sun, 11 Sep 2005 19:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:463641</guid><dc:creator>dancre</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dancre/comments/463641.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dancre/commentrss.aspx?PostID=463641</wfw:commentRss><description>I'll be speaking at PDC 2005 this year. I'll post more information soon. I hope to meet a bunch of you there - it's going to be a fun PDC!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=463641" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dancre/archive/tags/pdc2005/default.aspx">pdc2005</category></item></channel></rss>