<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Software and UX &#187; animation</title>
	<atom:link href="http://sweux.com/blogs/pombeiro/index.php/tag/animation/feed/" rel="self" type="application/rss+xml" />
	<link>http://sweux.com/blogs/pombeiro</link>
	<description>Thoughts and links on User Experience, Software Architecture</description>
	<lastBuildDate>Sat, 21 Aug 2010 21:36:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Animating the Visibility property</title>
		<link>http://blog.pedropombeiro.com/2009/08/animating-the-visibility-property/</link>
		<comments>http://blog.pedropombeiro.com/2009/08/animating-the-visibility-property/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 22:28:00 +0000</pubDate>
		<dc:creator>Pedro Pombeiro</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://sweux.com/blogs/pombeiro/index.php/2009/08/30/animating-the-visibility-property/</guid>
		<description><![CDATA[This post is sort of a future reference for myself. I needed to animate the Visibility property as part of a larger Storyboard, and it wasn’t immediately apparent how to do it. It took a bit of effort to find the solution on Google, so I am posting the solution in hope that it will [...]]]></description>
			<content:encoded><![CDATA[<p>This post is sort of a future reference for myself. I needed to animate the Visibility property as part of a larger Storyboard, and it wasn’t immediately apparent how to do it. It took a bit of effort to find the solution on <a href="http://www.google.com/search?hl=en&amp;rls=com.microsoft%3Aen-US%3AIE-SearchBox&amp;q=Visibility+setter+Storyboard&amp;aq=f&amp;oq=&amp;aqi=">Google</a>, so I am posting the solution in hope that it will make someone else’s life easier as well.</p>
<p>If you have something like the following, for an object that is usually hidden:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;Visibility&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;Visible&quot; /&gt;
</span></pre>
<p>and you want to fade in the object instead of suddenly showing it, you will need to convert the Setter into an Animation action in a Storyboard. You are probably aware of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation.aspx">DoubleAnimation</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.booleananimationusingkeyframes.aspx">BooleanAnimationUsingKeyFrames</a> classes already. To animate the Visibility property, however – which is an enum –, the solution is not immediately apparent: you need to use <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.objectanimationusingkeyframes.aspx">ObjectAnimationUsingKeyFrames</a>:<span style="color: blue"></span></p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Storyboard</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">ObjectAnimationUsingKeyFrames </span><span style="color: red">Storyboard.TargetProperty</span><span style="color: blue">=&quot;Visibility&quot;&gt;
        &lt;</span><span style="color: #a31515">DiscreteObjectKeyFrame </span><span style="color: red">KeyTime</span><span style="color: blue">=&quot;00:00:00&quot;&gt;
            &lt;</span><span style="color: #a31515">DiscreteObjectKeyFrame.Value</span><span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">Visibility</span><span style="color: blue">&gt;</span><span style="color: #a31515">Visible</span><span style="color: blue">&lt;/</span><span style="color: #a31515">Visibility</span><span style="color: blue">&gt;
            &lt;/</span><span style="color: #a31515">DiscreteObjectKeyFrame.Value</span><span style="color: blue">&gt;
        &lt;/</span><span style="color: #a31515">DiscreteObjectKeyFrame</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">ObjectAnimationUsingKeyFrames</span><span style="color: blue">&gt;

    &lt;</span><span style="color: #a31515">DoubleAnimation </span><span style="color: red">Duration</span><span style="color: blue">=&quot;00:00:01&quot; </span><span style="color: red">Storyboard.TargetProperty</span><span style="color: blue">=&quot;Opacity&quot; </span><span style="color: red">To</span><span style="color: blue">=&quot;1&quot; /&gt;
&lt;/</span><span style="color: #a31515">Storyboard</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><span style="color: blue"></span>There you go. The animation will start by making the object visible, and then animating it to 100% opaque. Hope this helps you!</p>
<p><a rev="vote-for" href="http://dotnetshoutout.com/Changing-an-Enum-property-value-in-a-Storyboard-or-Animating-the-Visibility-property"><img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fsweux.com%2Fblogs%2Fpombeiro%2Findex.php%2F2009%2F08%2F30%2Fanimating-the-visibility-property%2F" style="border:0px"/></a></p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsweux.com%2fblogs%2fpombeiro%2findex.php%2f2009%2f08%2f30%2fanimating-the-visibility-property%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsweux.com%2fblogs%2fpombeiro%2findex.php%2f2009%2f08%2f30%2fanimating-the-visibility-property%2f&#038;bgcolor=FF6633" border="0" alt="kick it on DotNetKicks.com" /></a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property&amp;bodytext=This%20post%20is%20sort%20of%20a%20future%20reference%20for%20myself.%20I%20needed%20to%20animate%20the%20Visibility%20property%20as%20part%20of%20a%20larger%20Storyboard%2C%20and%20it%20wasn%E2%80%99t%20immediately%20apparent%20how%20to%20do%20it.%20It%20took%20a%20bit%20of%20effort%20to%20find%20the%20solution%20on%20Google%2C%20so%20I%20am%20posting" title="Digg"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property&amp;notes=This%20post%20is%20sort%20of%20a%20future%20reference%20for%20myself.%20I%20needed%20to%20animate%20the%20Visibility%20property%20as%20part%20of%20a%20larger%20Storyboard%2C%20and%20it%20wasn%E2%80%99t%20immediately%20apparent%20how%20to%20do%20it.%20It%20took%20a%20bit%20of%20effort%20to%20find%20the%20solution%20on%20Google%2C%20so%20I%20am%20posting" title="del.icio.us"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property" title="DotNetKicks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property" title="DZone"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F" title="Technorati"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property&amp;source=Software+and+UX+Thoughts+and+links+on+User+Experience%2C+Software+Architecture&amp;summary=This%20post%20is%20sort%20of%20a%20future%20reference%20for%20myself.%20I%20needed%20to%20animate%20the%20Visibility%20property%20as%20part%20of%20a%20larger%20Storyboard%2C%20and%20it%20wasn%E2%80%99t%20immediately%20apparent%20how%20to%20do%20it.%20It%20took%20a%20bit%20of%20effort%20to%20find%20the%20solution%20on%20Google%2C%20so%20I%20am%20posting" title="LinkedIn"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property&amp;annotation=This%20post%20is%20sort%20of%20a%20future%20reference%20for%20myself.%20I%20needed%20to%20animate%20the%20Visibility%20property%20as%20part%20of%20a%20larger%20Storyboard%2C%20and%20it%20wasn%E2%80%99t%20immediately%20apparent%20how%20to%20do%20it.%20It%20took%20a%20bit%20of%20effort%20to%20find%20the%20solution%20on%20Google%2C%20so%20I%20am%20posting" title="Google Bookmarks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;title=Animating%20the%20Visibility%20property" title="StumbleUpon"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Animating%20the%20Visibility%20property&amp;body=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F" title="email"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-the-visibility-property%2F&amp;partner=sociable" title="Print"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.pedropombeiro.com/2009/08/animating-the-visibility-property/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Animating a data-bound color property</title>
		<link>http://blog.pedropombeiro.com/2009/08/animating-a-data-bound-color-property</link>
		<comments>http://blog.pedropombeiro.com/2009/08/animating-a-data-bound-color-property#comments</comments>
		<pubDate>Mon, 17 Aug 2009 09:26:00 +0000</pubDate>
		<dc:creator>Pedro Pombeiro</dc:creator>
				<category><![CDATA[Scrum Sprint Monitor]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://sweux.com/blogs/pombeiro/index.php/2009/08/17/animating-a-data-bound-color-property/</guid>
		<description><![CDATA[As I was going through the UI of the Scrum Sprint Monitor to introduce animations to the larger UI elements, one type of property was proving difficult to animate: the dynamic background color of some elements which were bound to Brush (or Color) properties of the ViewModel. Picture this: you have a Color property that [...]]]></description>
			<content:encoded><![CDATA[<p>As I was going through the UI of the <a href="http://scrumsprintmonitor.codeplex.com/" target="_blank">Scrum Sprint Monitor</a> to introduce animations to the larger UI elements, one type of property was proving difficult to animate: the dynamic background color of some elements which were bound to Brush (or Color) properties of the ViewModel. </p>
<p><em>Picture this: you have a Color property that is currently Green. At some point it changes to Red. You would like the UI to update smothly, so you would not see the color jump from Green to Red. You are not able to do this in XAML with triggers and storyboards directly.</em> The problem lies in the fact is that the Animation objects in XAML cannot be bound to dynamic values (see instances <a href="http://www.eggheadcafe.com/software/aspnet/29956953/problem-binding-animation.aspx" target="_blank">here</a> and <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9336022f-badb-4b40-a86c-a50ab1a64ba5" target="_blank">here</a>), as they must be <a href="http://msdn.microsoft.com/en-us/library/ms750509.aspx" target="_blank">frozen</a> for performance and thread safety reasons.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">DataTemplate </span><span style="color: red">DataType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">ViewModels</span><span style="color: blue">:</span><span style="color: red">BuildStatusBackgroundViewModel</span><span style="color: blue">}&quot;&gt;
    &lt;</span><span style="color: #a31515">Grid </span><span style="color: red">Background</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Path</span><span style="color: blue">=BuildStatusColor</span><span style="color: blue">}&quot; /&gt;
&lt;/</span><span style="color: #a31515">DataTemplate</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Therefore there is no point in trying to introduce triggers (be it EventTriggers or DataTriggers) in this Grid element. What I ended up doing is deriving a class from Grid and spawning the animation from code behind.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">DataTemplate </span><span style="color: red">DataType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">ViewModels</span><span style="color: blue">:</span><span style="color: red">BuildStatusBackgroundViewModel</span><span style="color: blue">}&quot;&gt;
    &lt;</span><span style="color: #a31515">Controls</span><span style="color: blue">:</span><span style="color: #a31515">BuildStatusBorder </span><span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">DataTemplate</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>See the code-behind example <a href="http://scrumsprintmonitor.codeplex.com/sourcecontrol/changeset/view/26988?projectName=scrumsprintmonitor#648227" target="_blank">here</a>. I did encounter a pitfall while developing this approach. I ran into a “Cannot freeze this Storyboard timeline tree for use across threads” exception, when the animation was kicked off. I fixed this by cloning the existing property value, essentially removing any data binding from the property.</p>
<p>Hope this helps someone who is running into the same problem of animating transitions between databound properties!</p>
<p><a href="http://dotnetshoutout.com/Animating-a-data-bound-color-property-Software-and-UX" rev="vote-for"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fsweux.com%2Fblogs%2Fpombeiro%2Findex.php%2F2009%2F08%2F17%2Fanimating-a-data-bound-color-property%2F" /></a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property&amp;bodytext=As%20I%20was%20going%20through%20the%20UI%20of%20the%20Scrum%20Sprint%20Monitor%20to%20introduce%20animations%20to%20the%20larger%20UI%20elements%2C%20one%20type%20of%20property%20was%20proving%20difficult%20to%20animate%3A%20the%20dynamic%20background%20color%20of%20some%20elements%20which%20were%20bound%20to%20Brush%20%28or%20Color%29%20pro" title="Digg"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property&amp;notes=As%20I%20was%20going%20through%20the%20UI%20of%20the%20Scrum%20Sprint%20Monitor%20to%20introduce%20animations%20to%20the%20larger%20UI%20elements%2C%20one%20type%20of%20property%20was%20proving%20difficult%20to%20animate%3A%20the%20dynamic%20background%20color%20of%20some%20elements%20which%20were%20bound%20to%20Brush%20%28or%20Color%29%20pro" title="del.icio.us"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property" title="DotNetKicks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property" title="DZone"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property" title="Technorati"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property&amp;source=Software+and+UX+Thoughts+and+links+on+User+Experience%2C+Software+Architecture&amp;summary=As%20I%20was%20going%20through%20the%20UI%20of%20the%20Scrum%20Sprint%20Monitor%20to%20introduce%20animations%20to%20the%20larger%20UI%20elements%2C%20one%20type%20of%20property%20was%20proving%20difficult%20to%20animate%3A%20the%20dynamic%20background%20color%20of%20some%20elements%20which%20were%20bound%20to%20Brush%20%28or%20Color%29%20pro" title="LinkedIn"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property&amp;annotation=As%20I%20was%20going%20through%20the%20UI%20of%20the%20Scrum%20Sprint%20Monitor%20to%20introduce%20animations%20to%20the%20larger%20UI%20elements%2C%20one%20type%20of%20property%20was%20proving%20difficult%20to%20animate%3A%20the%20dynamic%20background%20color%20of%20some%20elements%20which%20were%20bound%20to%20Brush%20%28or%20Color%29%20pro" title="Google Bookmarks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;title=Animating%20a%20data-bound%20color%20property" title="StumbleUpon"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Animating%20a%20data-bound%20color%20property&amp;body=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property" title="email"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimating-a-data-bound-color-property&amp;partner=sociable" title="Print"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.pedropombeiro.com/2009/08/animating-a-data-bound-color-property/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Animated WPF Panels (animating collection views)</title>
		<link>http://blog.pedropombeiro.com/2009/08/animated-panels/</link>
		<comments>http://blog.pedropombeiro.com/2009/08/animated-panels/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 17:01:00 +0000</pubDate>
		<dc:creator>Pedro Pombeiro</dc:creator>
				<category><![CDATA[Scrum Sprint Monitor]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[UX]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://sweux.com/blogs/pombeiro/index.php/2009/08/14/animated-panels/</guid>
		<description><![CDATA[This article presents new classes that extend the stock WPF panel classes. They add animation behavior in response to changes in the bound collection (demo video included).]]></description>
			<content:encoded><![CDATA[<p><font color="#ff0000">UPDATE: The same functionality is now available out of the box using the Blend 3 SDK, through the FluidMoveBehavior. Just drag that behavior to your container panel, and set the Duration and AppliesTo properties! The only difference is that easing functions are not yet supported in WPF. We will need to wait until WPF 4 is released.</font></p>
<p>Last evening I finally implemented a long awaited feature (by me!) in the <a href="http://scrumsprintmonitor.codeplex.com/">Scrum Sprint Monitor</a>: animated WPF panels. As the team members in the Sprint move up and down the list (an <a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx" target="_blank">ObservableCollection&lt;&gt;</a>), get added or removed, I always wished that change could be animated. My current knowledge of the WPF layout mechanism wasn’t sufficient to finish on that endeavor within a few hours, though.</p>
<p>I finally found a <a href="http://codeblitz.wordpress.com/2009/03/20/wpf-auto-arrange-animated-panel/" target="_blank">blog post</a> that set me on the right path, on Ed Foh’s blog. Ed in turn was inspired by Kevin Moore’s <a title="WPF Bag of Tricks" href="http://j832.com/bagotricks/">WPF Bag of Tricks</a>, which also includes an Animating Tile Panel.</p>
<p>Here is a video demonstrating the enhanced behavior of my <a href="http://scrumsprintmonitor.codeplex.com/sourcecontrol/changeset/view/26878?projectName=scrumsprintmonitor#646994" target="_blank">AnimatedUniformGrid</a>:</p>
<div style="padding-bottom: 15px; margin: 0px; padding-left: 0px; width: 599px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d33a49e7-f3b9-49c7-9cae-7414480784db" class="wlWriterSmartContent">
<div><embed height="355" type="application/x-shockwave-flash" width="425" src="http://www.youtube.com/v/raikaobT0WQ&amp;hl=en" /> </div>
<div style="clear: both; font-size: 0.8em">An AnimatedUniformGrid in action</div>
</p></div>
<h3>Why those two solutions didn’t work for me</h3>
<p>Both of the aforementioned solutions contained hardwired positioning logic, though. I simply needed to add the animation behavior to <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx" target="_blank">StackPanel</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx" target="_blank">WrapPanel</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.uniformgrid.aspx" target="_blank">UniformGrid</a>, not a completely custom panel. Ideally, the solution would be a behavior that could be added on top of those containers. That particular aspect wasn’t realized, and I ended up deriving classes for each of these panels, prefixing the new classes with “Animated”. It is still a pretty acceptable solution. <font color="#ff0000">UPDATE: I eventually found this was the same approach taken by at least one commercial offer.</font></p>
<p>The following is the code required to instantiate the uniform grid (note how you simple need to prefix the panel class with Wpf:Animated):</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">ItemsControl </span><span style="color: red">ItemsSource</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">TeamMembersIncludingUnassigned</span><span style="color: blue">}&quot;</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">ItemsControl.ItemsPanel</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">ItemsPanelTemplate</span><span style="color: blue">&gt;
         &lt;</span><span style="color: #a31515">Wpf</span><span style="color: blue">:</span><span style="color: #a31515">AnimatedUniformGrid </span><span style="color: red">Duration</span><span style="color: blue">=&quot;00:00:01&quot; /&gt;
      &lt;/</span><span style="color: #a31515">ItemsPanelTemplate</span><span style="color: blue">&gt;
   &lt;/</span><span style="color: #a31515">ItemsControl.ItemsPanel</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">ItemsControl</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>&#160;</h3>
<h3>Adding animation to an existing panel control class</h3>
<p>The workflow for converting an existing Panel to an AnimatedPanel is pretty easy:</p>
<ol>
<li>derive a new class from the desired panel class (prefix it with Animated); </li>
<li>override the ArrangeOverride method in the new class (don’t call the base class implementation); </li>
<li>using <a href="http://www.red-gate.com/products/reflector/">.NET Reflector</a>, extract the ArrangeOverride method contents from the base class implementation, and simply substitute the element.Arrange call that is performed for each child for a call to the <a href="http://scrumsprintmonitor.codeplex.com/sourcecontrol/changeset/view/26878?projectName=scrumsprintmonitor#646992" target="_blank">AnimatedPanelHelper</a>.ArrangeChild() static method. </li>
</ol>
<p>That is all you need to do!</p>
<h3>Acknowledgements</h3>
<p>Thanks to Ed Foh and Kevin Moore for their great work.</p>
<p>Download the source code <a href="http://blogs.sweux.com/pombeiro/wp-content/uploads/2009/08/AnimatedPanels.zip">here</a>.</p>
<div><a href="http://dotnetshoutout.com/Animated-WPF-Panels-Software-and-UX" rev="vote-for"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fsweux.com%2Fblogs%2Fpombeiro%2Findex.php%2F2009%2F08%2F14%2Fanimated-panels%2F" /></a></div>
<div>&#160;</div>
<div><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsweux.com%2fblogs%2fpombeiro%2findex.php%2f2009%2f08%2f14%2fanimated-panels%2f"><img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsweux.com%2fblogs%2fpombeiro%2findex.php%2f2009%2f08%2f14%2fanimated-panels%2f&amp;bgcolor=FF6633" /></a></div>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29&amp;bodytext=This%20article%20presents%20new%20classes%20that%20extend%20the%20stock%20WPF%20panel%20classes.%20They%20add%20animation%20behavior%20in%20response%20to%20changes%20in%20the%20bound%20collection%20%28demo%20video%20included%29." title="Digg"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29&amp;notes=This%20article%20presents%20new%20classes%20that%20extend%20the%20stock%20WPF%20panel%20classes.%20They%20add%20animation%20behavior%20in%20response%20to%20changes%20in%20the%20bound%20collection%20%28demo%20video%20included%29." title="del.icio.us"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29" title="DotNetKicks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29" title="DZone"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F" title="Technorati"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29&amp;source=Software+and+UX+Thoughts+and+links+on+User+Experience%2C+Software+Architecture&amp;summary=This%20article%20presents%20new%20classes%20that%20extend%20the%20stock%20WPF%20panel%20classes.%20They%20add%20animation%20behavior%20in%20response%20to%20changes%20in%20the%20bound%20collection%20%28demo%20video%20included%29." title="LinkedIn"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29&amp;annotation=This%20article%20presents%20new%20classes%20that%20extend%20the%20stock%20WPF%20panel%20classes.%20They%20add%20animation%20behavior%20in%20response%20to%20changes%20in%20the%20bound%20collection%20%28demo%20video%20included%29." title="Google Bookmarks"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;title=Animated%20WPF%20Panels%20%28animating%20collection%20views%29" title="StumbleUpon"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Animated%20WPF%20Panels%20%28animating%20collection%20views%29&amp;body=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F" title="email"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fblog.pedropombeiro.com%2F2009%2F08%2Fanimated-panels%2F&amp;partner=sociable" title="Print"><img src="http://sweux.com/blogs/pombeiro/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.pedropombeiro.com/2009/08/animated-panels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
