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.]

(Shows the Coverflow view with Reflections)

 

(Shows 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 :)

Technorati tags: , , , , ,

Similar Posts:

29 responses to “The ElementFlow custom control – can do CoverFlow too!”

  1. Mikael
    How much have you got left,
    Why dot you release a test app. 
  2. VinodhRajasekharan

    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…

  3. Pavan Podila

    Hi Mikael,
         I still haven’t released the code. Will put up a post when I do that.
    Appreciate your interest.

    Cheers!
    Pavan

  4. Mikael
    Can you give some link to download.
    I want to implement it in my app.
  5. Pavan Podila

    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!

  6. 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

  7. Pavan Podila

    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

  8. 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

  9. Dananjay Anandan

    very neat! saw the video on yt and followed the link.

  10. Rodrigo Ratan
    great stuff!
  11. Pavan Podila

    Steve,
         At this moment the control is internal but that may change. I will keep everyone updated through this blog.

  12. (no name)

    Nice job!  That looks great.  Will this be available for sale/download? looking to implement something like this shortly. When!?

    very cool

    -steve

  13. Boris
    Pavan, you did it again- thats amazing stuff!
    Id love to learn more about that- pleeeease release the code..
  14. Dr Click
    i want to implement this with silverlight. And thoughts on how this could be done? 
  15. (no name)

    Love to see the source

  16. (geen naam)
    Nice ! Can’t wait ’till you release the source code.
    We’ve seen this kind of thing before but not as flexible, IMHO.
  17. (no name)

    Very cool stuff.

  18. Scott Wojan

    When do you think you will release the control?

  19. dougmccune.com » Blog Archive » Where are the dope Silverlight demos?

    [...] had that moment when I saw Pavan Podila’s WPF example of doing 3D layouts with WPF. That blew me away (he made it back in June) and I realized that WPF ain’t nothing to fuck [...]

  20. David

    Hi Pavan,

    I downloaded your project from CodePlex. It is very cool! It appears as though there is a slight but though.

    I noticed that when you run the ElementFlow program in the default view and you add a bunch of items, then you can see through the reflections of the elements on the right side, but the reflections on the left side look opaque. Either way looks okay, but the fact that they are inconsistent is a little odd.

    I examined the code, and the only thing that I can think is that this is not a bug which is in your code, rather, it appears to be a problem with the actual ViewPort3D. Updates to the z-order of the items in the 3D scene do not appear to affect the transparent elements. This is also very apparent in another one of the views.

    I can think of a potential fix. That is, manually resort the items in the scene. Do you have any thoughts on this issue?

    Thanks!

  21. David

    Sorry, by slight “but”, I meant slight “bug”.

    Thanks again.

  22. David

    Sure, I’ll vote.

    One last thing. Would it be easy to adapt this code to make the control wrap around, like a carousel control, so instead of reaching the end of the collections of items you can just continually scroll through them?

    It seems like the z-order issue would be more pronounced if you did something like this. But it would add to the number of scenarios where the controls would be useful.

    They really look great though.

  23. xtqxk

    good!super good!

  24. tung

    i want when i click in each picture will bi appear a popup windows to show detail picture. i can’t override function

    can you help me

  25. .NET i jiné ... : Odkazy z prohlíže?e – 11.4.2010

    [...] The ElementFlow custom control – can do CoverFlow too! – kontroly pro krásné carousel efekty ve WPF [...]

  26. Updated: PlexiGlass (OpenFlux 3D) Example | Ryan Campbell

    [...] Since my previous entry I've made some major speed improvements, added back in the 52 cards and added 2 new 3d layouts similar to the ones in Pavan Podila's Element Flow. [...]

Leave a Reply