Pavan 的个人资料the WPF way...日志列表 工具 帮助
2007/6/5

The ElementFlow custom control - can do CoverFlow too!

I am sure many of you have heard and even interacted with the CoverFlow view of iTunes. In the WPF world we have the good folks from Thirteen23, who have created an app called Harmony that shows off the use of CoverFlow. They make good use of the Viewport3D to pull the desired effect.

Recently I had the opportunity to develop a custom control similar to CoverFlow. I call this control the ElementFlow, because besides CoverFlow, the control can do lots of other views. In fact the whole view part of the control has been abstracted out so you can plug in your own view (if you wish). This is possible by creating a new ViewState and providing the necessary animations to flow the items.

Since the control is supposed to layout a list of items, it behaves very similar to an ItemsControl. However for various reasons I have not derived from ItemsControl (Why? - that's a topic of a different blog post).

To demonstrate this control I have captured two videos, one which contains reflections and one without. In the first one I show only the CoverFlow control (with reflections ON). In the second video (reflections OFF) I start with the CoverFlow view and then switch my ViewStates. You can see that the view transition is very fluid and the selected-item is retained on different ViewStates. [Note that not all layout-related dependency properties have mappings for different ViewStates.]

 
YouTube - ElementFlow control (showing CoverFlow with reflection)

 

 
YouTube - ElementFlow control - showing other ViewStates

 

Some of the inner workings

  • There are two ways in which you can add items to the ElementFlow control: creating the UIElement directly or by specifying a ElementsSource and ElementTemplate. Whenever an item is added, it is kept hidden separately and a VisualBrush of that item is texture-mapped onto the 3D Mesh. The mesh is then positioned according to its item-index in the list.
  • I derive from a FrameworkElement instead of ItemsControl.
  • To change the visual tree I override the following methods: GetVisualChild(), ArrangeOverride(), MeasureOverride() and the property: VisualChildrenCount
  • Viewport3D is my only visual-child

 

What are the features of this control?

  • Can do multiple forms of 3D list visualizations using ViewStates. Some of the out-of-box ViewStates include: CoverFlow, RollerCoaster, TimeMachine, Rolodex
  • Pluggable ViewStates
  • Fluid animations when switching between ViewStates
  • Items can be added directly via XAML or in code using the Children property
  • Supports data-binding via ElementsSource + ElementTemplate
  • Detects changes to collection - Add/Remove/Update
  • Various properties to control layout of items - ItemGap, FrontItemGap, PopoutDistance, TiltAngle. Changing these properties causes animated changes on the view.
  • Mouse, Keyboard and Mousewheel interaction

 

Future updates

  • Virtualization of the view when dealing with a huge collection. Got to dig up those posts by Dan Crevier and Ben Constable :), think VirtualizingStackPanel and IScrollInfo !!
  • I can't release the Source code yet but keep visiting back :)

 

评论 (19)

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。
PodilaPava​n 在此页禁用了评论功能。
Hello everyone,
        Please visit my new blog at http://blog.pixelingene.com . I will be maintaining this blog but all future posts will be made at the new blog.

Thanks!
1 月 24 日

This is a great video. Pavan did an awesome job in this video. I am inpatient and it seems everyone on this post has been waiting for 6 months at least. Trying to get an idea on where to start to make my own I came across a link to a element flow / cover flow example by “mentas”. It is intended for Silverlight which is a plus. The logic and code behind is there.

 

I am creating a custom control by implementing “mentas” logic and tweaking it to my needs. The control will throw the elements in 3D space allowing rotation. I have a Beta in VB.net if anyone is interested. Contact me through my MSN spaces page. I will send you a download link for the source code. Once I clean it up I will post it for public viewing and download, until then just by request. Hope this helps everyone.

 

-- Chris

1 月 24 日
Mikael发表:
How much have you got left,
Why dot you release a test app. 
1 月 18 日
Hi pavan! I'm dieing to see the code behind this great control...I request you to write an article in code project about how you did this so that more people can get to know your great control..I'm an UG student & I'm planning a project in which your control could be of great help for me...so plz do post the code or  the control ASAP...
      
12 月 21 日
Hi Mikael,
     I still haven't released the code. Will put up a post when I do that.
Appreciate your interest.


Cheers!
Pavan
12 月 6 日
Mikael发表:
Can you give some link to download.
 
I want to implement it in my app.
12 月 3 日
Hi Fanou,
         I certainly wish that I can post the source and also explain the techniques. However some of the stuff is proprietary and thus I am limited in certain ways.

There are lot of interesting things in ElementFlow that give a new perspective at control development. There are tricks with Storyboards, 3D meshes, layout, design patterns, event/input handling that may not seem obvious. I shall certainly post more in the future.

Thanks!
12 月 1 日
匿名 的图片
Fanou360 发表:
Your work seems to be very powerfull. You said that you can't release the source code yep but "keep visiting back". Can you tel us when you will explain your work or just release your code ?
Congratulations again

11 月 30 日
Hi MueMeister,
     I made a change to the ElementFlow control sometime back ... this may be what you are looking for : http://pavanpodila.spaces.live.com/blog/cns!9C9E888164859398!468.entry
11 月 28 日
匿名 的图片
MueMeister 发表:
Hi,

Why did you used a FrameworkElement instead of ItemsControl. I don't understand
the fact cause you loose the abilities exposed by the ItemsControl-paradigm hich
i shiped with WPF.
New views has to follow your rules instead of using DataTemplates and ControlTemplates
for item containers e.g. (correct me if this is not true)

TIA
MueMeister
11 月 28 日
very neat! saw the video on yt and followed the link.
11 月 26 日
great stuff!
10 月 12 日
Steve,
     At this moment the control is internal but that may change. I will keep everyone updated through this blog.
8 月 25 日
Steve发表:
Nice job!  That looks great.  Will this be available for sale/download? looking to implement something like this shortly. When!?

very cool

-steve
8 月 24 日
匿名 的图片
Boris 发表:
Pavan, you did it again- thats amazing stuff!
Id love to learn more about that- pleeeease release the code..
8 月 17 日
Dr Click发表:
i want to implement this with silverlight. And thoughts on how this could be done? 
8 月 16 日
匿名 的图片
(no name) 发表:
Love to see the source
6 月 27 日
Sven发表:
Nice ! Can't wait 'till you release the source code.
We've seen this kind of thing before but not as flexible, IMHO.
6 月 5 日
没有名字发表:
Very cool stuff.
6 月 5 日

引用通告

此日志的引用通告 URL 是:
http://pavanpodila.spaces.live.com/blog/cns!9C9E888164859398!380.trak
引用此项的网络日志