Wednesday, 26 November 2008

In my previous post, I introduced my thoughts on how animation between positions should be done. Today I will walk you through some of the technical benefits of that approach with a cool animated wrappanel sample. Yes, the silverlight control toolkit includes a wrappanel. Let’s animate it, the easy way!

Sample

I got some feedback that the samples that I inlined were not visible from rss feeds. So, visit this page to see the sample in action.

image

Please note the big black slider on the right.. Drag it to the left to do some layout transitions between items.
Also, to illustrate the flexibility of this approach, there is a textbox on the top that determines the startdelay of the items (Random between 0 and the number you give it). Set it to 700 milliseconds and then quickly drag the slider to the left. You will see some items moving immediately, others moving after some time. This gives it a less ‘plastic-fantastic’ feel.

The items are shown on the page using the xaml below. Notice how I use a regular wrappanel as ItemsPanelTemplate.

        <ItemsControl Grid.Row="1" x:Name="anim" HorizontalAlignment="Left">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ItemMovementSpike:MoveableItem Margin="10">
                        <Border Background="Yellow" Width="80" Height="80" >
                            <ContentPresenter Content="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Border>
                    </ItemMovementSpike:MoveableItem>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Controls:WrapPanel/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemsSource>
                <Controls:ObjectCollection>
                    <System:String>1</System:String>
                    <System:String>2</System:String>
                    <System:String>3</System:String>
                    <System:String>4</System:String>
                    <System:String>5</System:String>
                    <System:String>6</System:String>
                    <System:String>7</System:String>
                    <System:String>8</System:String>
                    <System:String>9</System:String>
                    <System:String>10</System:String>
                    <System:String>11</System:String>
                    <System:String>12</System:String>
                    <System:String>13</System:String>
                    <System:String>14</System:String>
                </Controls:ObjectCollection>
            </ItemsControl.ItemsSource>
</ItemsControl>

 

Again: who does the animation? Panel or the item

One of the first samples on layout transitions inside a panel are from Dave Relyea (DevDave) and can be seen here. The big difference between the approaches is that he uses a custom-made wrappanel, which does the layout transition.

As you can remember from my previous post, I believe that a panel should only calculate and determine the actual logical position of an item. The transition between positions is not the concern of the panel and should be handled by some other dedicated object. In this case, you can see that I’ve chosen to wrap my content inside of a ‘MoveableItem’ whose concern it is to transition between positions.

As discussed, it is a pity that we have to work so hard inside of MoveableItem, because panels do not notify their children about a position change. But it can be done fairly efficient.

C’mon, isn’t the panel responsible for layout.. So it is HIS concern!

No sir, I strongly disagree. The panel is responsible for the layout of an element on the screen, sure. But they exist in all kinds of forms (Grid, dockpanel, wrappanel) and the intent is to determine the end position as quickly as possible. I feel it is not okay to start mixing that concern with an animation framework.
As always, a class should have only 1 reason to change. A panel should only be changed to alter the layout logic, not because we decided to add features to our transitioning logic.

What are the benefits of separating these concerns

By letting a panel be a panel, and having another class handle the transition, you get a much cleaner model.
First and foremost, we now do not have to alter panels in order to use animation. Most of the solutions I have seen require you to change the baseclass of your panel. This means you can not easily leverage the panels that someone else created, like the toolkits WrapPanel or DockPanel or the build-in Grid and StackPanel! It would mean creating your own versions of these panels. If you’re on the Silverlight side, you may copy our source and change the baseclass, but that will be pretty hard to do for a Grid in any case.

Second, designtime experience. Although I setup my animation in code at this moment, MoveableItem could also just go to a different visual state: ‘Moved’ and allow you to use Blend to create a transition yourself! This would be very easy to do, because MoveableItem could just expose a double where 1 means: in endposition and 0 means: in beginposition. That double could be easily animated using keysplines to create cool effects. See my expander series for more on that approach. I might follow up with a complete sample.

Stretching it a bit, I feel these come into play as well:

Flexibility. I can think of quite a few interesting properties I might want to set on my ‘MoveableItem’, like Weight, Gravity and so on. We could plugin Penner-equations (like, easeIn, bounce etc.) at the item level in a very clean way (cleaner than attached properties).

Performance. The effects I am thinking of go beyond mere transitions. For instance, it might take one item some time to ‘settle-in’: slowly rocking for some time before it finally goes silent. Others might have settled earlier. A panel keeps performing arrange overrides to allow for this. This is overkill.

Conclusion

I find this an intriguing topic. I know people have been using transitioning panels for quite some time now and are very comfortable with it. I hope that this post does make you think though, even though you might completely disagree :)
Let me know either way!

Saturday, 14 February 2009 20:55:55 (Romance Standard Time, UTC+01:00)
Brilliant! I totally agree here. Why should I have to extend every panel I want to add animation to. This has bothered me to no end on pretty much all the other solutions out there. I learned a ton from your article and now am going to let it all soak in a bit before I try and get Storyboards and the VSM to work with your solution.
Shawn Gavin
Friday, 15 October 2010 01:21:48 (Romance Standard Time, UTC+01:00)
<p>Of the 30 million in the <a href="http://www.fivefingeronline.com/">vibram fivefingers</a> activities, 2010 non-environment-majors on China walk first stage <a href="http://www.fivefingeronline.com/">vibram five</a> activities, the poem ended Co., LTD. Offers outdoor products to both the retail price is lucky <a href="http://www.fivefingeronline.com/products_all.html">five finger</a> skywalker prize for ¥1980 German professional outdoor shoe in <a href="http://www.fivefingeronline.com/featured_products.html">vibram shoes</a> on GTX RENEGADE for hiking shoes. They will be wearing this pair of the world’s most powerful boots origin produces the boots top <a href="http://www.fivefingeronline.com/featured_products.html">five fingers</a> product officially began to walk.Called “outside” of the ID of the winners is walking <a href="http://www.fivefingeronline.com/products_new.html">vibram five finger</a> across the big horqin sandy land “green channel”. Inner Mongolia horqin sandy land and <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">fivefingers kso</a> liaoning, jilin across three provinces, 92% of eastern Inner Mongolia above <a href="http://www.fivefingeronline.com/products_new.html">vibram five fingers</a> distribution in chifeng city, area and the tongliao 5 million square <a href="http://www.fivefingeronline.com/specials.html">vibram five fingers shoes</a> kilometers, ranking first in four sand. Genghis khan’s <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">vibram kso</a> brother, and its subordinate subordinates’ called cheap five finger shoes, then formed by <a href="http://www.fivefingeronline.com/vibram-five-fingers-classic-c-76.html">vibram classic</a> tribe.In the first stage, the activity ended at the second stage, the second phase will start to Tibet, xinjiang, “stand in xinjiang, ningxia, Tibet, shaanxi, gansu, qinghai and within the <a href="http://www.fivefingeronline.com/vibram-five-fingers-flow-c-73.html">vibram flow</a> scope of land.</p>
<p>If you want to take part in outdoor activities, persistent and very love this <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">vibram fivefingers kso</a> sport, so choose cheap vibram is very important. A set of suitable equipment can indeed for our outdoor activities to provide protection, let us be more close to nature, feel nature.We choose to suit <a href="http://www.fivefingeronline.com/reviews.html">5fingers</a> oneself is suitable for environmental equipment, so we first concern is the applicability of the equipment, rather than spend less money for price, event, although is good, but usually sale <a href="http://www.fivefingeronline.com/vibram-five-fingers-speed-c-115.html">five finger speed</a> is reality, the most expensive sometimes are not is most appropriate. There is not expected to equipment can be armed to the teeth. A bite to eat dinner.</p>
<p><a href="http://www.fivefingeronline.com/">MBT shoes</a> have become increasingly popular. Because of its tremendous role to humans. <a href="http://www.fivefingeronline.com/products_all.html">mbt walking shoes</a> not only fashionable, but also healthy. I think this is more important is fashion. Swiss <a href="http://www.fivefingeronline.com/specials.html">mbt shoes sale</a>, Karl Mueller invented. His invention came to the United Kingdom. In tourism this journey, it can be found wearing <a href="http://www.fivefingeronline.com/products_new.html">mbt sale</a> can easily get ahead, he who is like a walk in the soft grass. It takes years of research and development, <a href="http://www.fivefingeronline.com/reviews.html">mbt shoes review</a> Sale market development began in 1996, selling over one million every year is growing <a href="http://www.fivefingeronline.com/">mbt footwear</a> rapidly.<a href="http://www.fivefingeronline.com/">http://www.fivefingeronline.com/</a> </p>
Friday, 15 October 2010 01:26:27 (Romance Standard Time, UTC+01:00)
3_103.html"><strong> </strong></a> are made more unique by the inclusion of a large wooden button with the Ugg logo on it and an elastic band closure. So it allows you to wear t
Just as with the <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-cardy-c-53_108.html"><strong>UGG boots</strong></a> the new calf high boot that this <a href="http://www.shoeslockers.com/ugg-boots-ugg-knightbridge-boots-c-53_118.html"><strong>Ugg Australia</strong></a> company have introduced the Bailey Button offers the same level of comfort. Certainly for women who are looking for a pair of <a href="http://www.shoeslockers.com/ugg-boots-ugg-lo-pro-button-c-53_124.html"><strong>UGG sale</strong></a> to team with jeans or a long skirt these are ideal.But as you will soon discover these <a href="http://www.shoeslockers.com/ugg-boots-ugg-bailey-button-c-5hem with this detailing on shown or you can undo the button and then turn the top over to create a cuff.With all the boots included in <a href="http://www.shoeslockers.com/ugg-boots-ugg-new-style-ultra-short-boots-c-53_122.html"><strong>Cheap UGG boots</strong></a> Australia’s Classic Collection range the <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-mini-c-53_114.html"><strong>UGG bailey button</strong></a> is lined with twin faced Grade A sheepskin. Also there is the traditional suede heel guard to ensure that not only is this area protected but offers this part of the <a href="http://www.shoeslockers.com/ugg-boots-ugg-bailey-button-fancy-c-53_102.html"><strong>UGG boots sale</strong></a> support. Plus within the <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-short-c-53_113.html"><strong>UGG classic cardy</strong></a> you find each pair has sock liners that are made from sheepskin PU foam so increasing the level of comfort a person feels when wearing <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-short-c-53_113.html"><strong>UGG short boots</strong></a>.<a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-tall-c-53_110.html"><strong>zigtech shoes</strong></a> is very unique. It uses an innovative lightweight foam materials,<a href="http://www.shoeslockers.com/reebok-zigtech-shoes-c-127.html"><strong>ZigTech trainers</strong></a> are designed to help you run further and faster, allowing you to train while using their unique <a href="http://www.shoeslockers.com/reebok-easytone-shoes-c-126.html"><strong>Easytone shoes</strong></a> harder for longer with reduced risk of injury. They do this by providing lots of cushioning Yesterday we saw the promo video featuring Thierry Henry and Lewis Hamilton talking about the trainers. So today we’re looking at the latest technical video released by Reebok to explain what <a href="http://www.shoeslockers.com/women-mbt-shoes-mbt-fora-shoes-c-49_61_66.html"><strong>Discount Reebok Easytone</strong></a> is and how the <a href="http://www.shoeslockers.com/ugg-boots-ugg-knightbridge-boots-c-53_118.html"><strong>zigtech sale</strong></a> sole works.in the Slinky-esque midsole/outsole that is said to reduce muscle wear and transfer energy. <a href="http://www.shoeslockers.com/ugg-boots-ugg-lo-pro-button-c-53_124.html"><strong>Reebok zigtech shoes</strong></a> Stadium bring an innovative technology shoes- <a href="http://www.shoeslockers.com/men-mbt-shoes-mbt-casual-shoes-c-49_54_55.html"><strong>Reebok easytone shoes</strong></a> training run. We series, is the best <a href="http://www.shoeslockers.com/products_new.html"><strong>Easy tone shoes</strong></a> sport technology to date. It can reduce 20% of the leg muscle fatigue and wear, in order to cultivate strength and degree of difficulty is significantly increased.<a href="http://www.shoeslockers.com/men-mbt-shoes-mbt-sandals-shoes-c-49_54_57.html"><strong>MBT shoes</strong></a> effect abdominal, leg and buttock muscles.cheap <a href="http://www.shoeslockers.com/mbt-shoes-men-mbt-shoes-c-49_54.html"><strong>Cheap mbt shoes</strong></a> looks sunny, so it is a good choice <a href="http://www.shoeslockers.com/mbt-shoes-c-49.html"><strong>MBT shoes sale</strong></a> believe that human fitness majestic, <a href="http://www.shoeslockers.com/skechers-shapeups-shapeups-sleek-fit-c-50_75.html"><strong>Skecher Shape Ups</strong></a> walk to a large extent. This view wholesale <a href="http://www.shoeslockers.com/women-mbt-shoes-mbt-lami-shoes-c-49_61_67.html"><strong>Discount MBT Shoes</strong></a> a number of scientific ,Therefore, majestic mbt shoes and strengthen peoples understanding <a href="http://www.shoeslockers.com/skechers-shapeups-shape-ups-stability-c-50_74.html"><strong>shape ups Shoes</strong></a> .in <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-tall-stripe-cable-c-53_101.html"><strong>shape up skechers</strong></a> through disseminate the majestic <a href="http://www.shoeslockers.com/ugg-boots-ugg-classic-tall-metallic-c-53_112.html"><strong>shape ups discount</strong></a> ideas and concepts.
Friday, 15 October 2010 08:43:47 (Romance Standard Time, UTC+01:00)
href="http://www.feetlockers.com/reebok-easytone-reebok-easytone-womens-shoes-c-25_28.html">Reebok Easytone Shoes</a> syndication. And then there are those who are having <a href="http://www.feetlockers.com/specials.html">Discount Reebok zigtech</a> trouble getting out of their own way.The folks who are not succeeding are the ones whose first question is “where do I find a good deal?” Early stage syndicators think they need to find a great deal, then raise capital, and they will be on their way toward success and profit. I usually counter that with some tough love and a reality check. Instead of looking for deals and Reebok shoes, a prudent <a href="http://www.feetlockers.com/reebok-easytone-reebok-zig-pulse-running-shoes-c-25_26.html">Reebok EasyTone</a> syndicator needs to put the horse in front of the deal, and start with the question of how to raise capital.
Friday, 15 October 2010 08:43:56 (Romance Standard Time, UTC+01:00)
back pain and lumbosacral joint.Moreover, the girls who wear high heels early will lead to <a href="http://www.zigtechshoesonsale.com/mbt-men-shoes-mbt-casual-shoes-c-8_9.html"><strong>Discount Mbt Shoes</strong></a> the developing pelvic tilt, which make the <a href="http://www.zigtechshoesonsale.com/mbt-men-shoes-mbt-sandals-shoes-c-8_11.html"><strong>Mbt shoes clearance</strong></a>, is demanding.However, they are not only for people on their feet but for anyone who wants to wear a pair of comfortable <a href="http://www.zigtechshoesonsale.com/mbt-women-shoes-mbt-sports-shoes-c-15_26.html"><strong>Mbt shoes outlet</strong></a> that takes the pain away from your body when you are standing and walking. That’s why you need to wear <a href="http://www.zigtechshoesonsale.com/mbt-men-shoes-mbt-casual-shoes-c-8_9.html"><strong>MBT Sandals Shoes</strong></a>.
Wednesday, 27 October 2010 09:57:43 (Romance Standard Time, UTC+01:00)
<p>Of the 30 million in the <a href="http://www.fivefingeronline.com/">vibram fivefingers</a> activities, 2010 non-environment-majors on China walk first stage <a href="http://www.fivefingeronline.com/">vibram five</a> activities, the poem ended Co., LTD. Offers outdoor products to both the retail price is lucky <a href="http://www.fivefingeronline.com/products_all.html">five finger</a> skywalker prize for ¥1980 German professional outdoor shoe in <a href="http://www.fivefingeronline.com/featured_products.html">vibram shoes</a> on GTX RENEGADE for hiking shoes. They will be wearing this pair of the world’s most powerful boots origin produces the boots top <a href="http://www.fivefingeronline.com/featured_products.html">five fingers</a> product officially began to walk.Called “outside” of the ID of the winners is walking <a href="http://www.fivefingeronline.com/products_new.html">vibram five finger</a> across the big horqin sandy land “green channel”. Inner Mongolia horqin sandy land and <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">fivefingers kso</a> liaoning, jilin across three provinces, 92% of eastern Inner Mongolia above <a href="http://www.fivefingeronline.com/products_new.html">vibram five fingers</a> distribution in chifeng city, area and the tongliao 5 million square <a href="http://www.fivefingeronline.com/specials.html">vibram five fingers shoes</a> kilometers, ranking first in four sand. Genghis khan’s <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">vibram kso</a> brother, and its subordinate subordinates’ called cheap five finger shoes, then formed by <a href="http://www.fivefingeronline.com/vibram-five-fingers-classic-c-76.html">vibram classic</a> tribe.In the first stage, the activity ended at the second stage, the second phase will start to Tibet, xinjiang, “stand in xinjiang, ningxia, Tibet, shaanxi, gansu, qinghai and within the <a href="http://www.fivefingeronline.com/vibram-five-fingers-flow-c-73.html">vibram flow</a> scope of land.</p>
<p>If you want to take part in outdoor activities, persistent and very love this <a href="http://www.fivefingeronline.com/vibram-five-fingers-kso-c-67.html">vibram fivefingers kso</a> sport, so choose cheap vibram is very important. A set of suitable equipment can indeed for our outdoor activities to provide protection, let us be more close to nature, feel nature.We choose to suit <a href="http://www.fivefingeronline.com/reviews.html">5fingers</a> oneself is suitable for environmental equipment, so we first concern is the applicability of the equipment, rather than spend less money for price, event, although is good, but usually sale <a href="http://www.fivefingeronline.com/vibram-five-fingers-speed-c-115.html">five finger speed</a> is reality, the most expensive sometimes are not is most appropriate. There is not expected to equipment can be armed to the teeth. A bite to eat dinner.</p>
<p><a href="http://www.fivefingeronline.com/">MBT shoes</a> have become increasingly popular. Because of its tremendous role to humans. <a href="http://www.fivefingeronline.com/products_all.html">mbt walking shoes</a> not only fashionable, but also healthy. I think this is more important is fashion. Swiss <a href="http://www.fivefingeronline.com/specials.html">mbt shoes sale</a>, Karl Mueller invented. His invention came to the United Kingdom. In tourism this journey, it can be found wearing <a href="http://www.fivefingeronline.com/products_new.html">mbt sale</a> can easily get ahead, he who is like a walk in the soft grass. It takes years of research and development, <a href="http://www.fivefingeronline.com/reviews.html">mbt shoes review</a> Sale market development began in 1996, selling over one million every year is growing <a href="http://www.fivefingeronline.com/">mbt footwear</a> rapidly.<a href="http://www.fivefingeronline.com/">http://www.fivefingeronline.com/</a> </p>
Friday, 29 October 2010 10:02:23 (Romance Standard Time, UTC+01:00)
http://www.coachusabags.com/
http://www.ukuggus.com/
http://www.asics-us.com/
http://www.mbt-usa.com/
Friday, 19 November 2010 06:26:38 (Romance Standard Time, UTC+01:00)
Such a very valuable information. Thanks for this excellent read.
Comments are closed.