Creating an Outlook Navigation Bar using the ListView and Accordion Controls

One of the designers on our UI team requested a screen mockup with a page layout that is similar to your typical email client.  The page is divided vertically into 2 panes.  The left pane contains a 2 level hierarchy of categories and subcategories.  As the user selects different subcategories the designer wants the right pane's content to be updated with the corresponding information.  Just like Outlook, the designer wants the subcategories to be displayed within expanding and collapsing panels.

I am familiar enough with the AjaxControlToolkit's Accordion control to know that it should be the right tool for the job here, but I haven't actually used it before.  So I did a little research on the Accordion and created a small demo page that we used to get a feel for how the control behaves and what it takes to build and style it.

Live Demo (IE6, IE7 and FF) | Download (.Net 3.5 and Toolkit Version 3.5.11119.0)

image

Overview of the Accordion AjaxControlToolkit Control

In case the Accordion control is brand new to you, here is the description of the control taken from the toolkit's documentation.

image

The Accordion is not the only toolkit control that allows you to provide multiple panes of content and display them one at a time, the Tab control does this as well.  The trick is deciding what control better meets your requirements.  For my scenario the choice was simple - my UI design team had already made this decision for me ;).  However, if you are interested in reading about the trade-offs between the general class of Tabs and Accordion presentation styles, I would recommend reading the following articles on UI patterns

While there are some visual differences between the Tab and Accordion controls, the markup for these two controls share a similar structure.  Just like the Tab control, there are templates provided for specifying the markup for the header and content of each of the AccordionPanes. 

Below are 2 sample screen shots of a simple Accordion Control that contains 2 panes of content: Mail and Notes.  Just below these screen shots is the markup I used to create these screen shots.  I in-lined some basic styles to make it easier to map the AccordionPanes markup to the screen shots .

image   image

image

Building the AccordionPane Content with the ListView

After I had the feel for what it takes to creating the individual AccordionPanes and a rough idea for how I wanted to present the sub-categories, I then started replacing the pane content with the new ListView control.  To do this, I removed the static UL/LI structure from the AccordionPane's Content section and replaced it with a ListView (which is now responsible for generating this content).  Making this replacement allows me to dynamically generate the UL/LI structure no matter how many subcategories there are.  Below is the new markup for the Notes panel.  

image 

Styling the Accordion

Now I have the basic structure I was looking for, but the style needs some work. 

Styling the Pane's Header

To style the pane headers, I used 2 images.  One for the background and another for the mouseover.

 

Styling the Pane's Content Background

To style the content background, I used the following background image.

Styling the Pane's UL/LI  

Styling the UL/LI was a little bit more difficult for cross browser support.  I started off using the LI's list-style-image property, but because of the differences in padding and margins used by the different browsers, this never rendered how I wanted in IE7.  So instead I followed this advise and used the LI's background property instead.  This worked much better.  Here are a few of the images I used for the Mail subcategories:

  

Because these images are specific to each individual item, I generated the in-line style rule using a databinding expression like so

image

By the way, all of the images for this sample were taken from ComponentArt's great looking Outlook 2003 NavBar example.  The download includes both PNG and GIF image formats.  I used GIF because I wanted to support IE6, but I included both just anyone would find them useful.

Important Accordion Properties

After I had the AccordionPane content rendering as desired, I started tweaking the behavior by modifying some the of properties the Accordion control exposes.  Here are a few of the ones that I found useful:

  • FadeTransitions
    • If you set this to true, a Fade Animation will be applied to the Accordion as the user transitions between selected panes.
  • RequireOpenPane
    • When this is set to true, the Accordion control will always have one pane open.  If you set it to false, the user can close the currently open pane by clicking on its header (leaving all of the panes closed).
  • AutoSize

image

  • SuppressHeaderPostbacks
    • When this is set to true, the Accordion will automatically suppress any postbacks that originate from controls contained within the AccordionPanes Header's.

A Few Things I Didn't Get To

  • Creating a sprite for the images
  • Using JavaScript instead of the :hover pseudo class for the Header hover style's
  • Looking into some weirdness with how the Accordion works when AutoSize is set to Fill

That's it.  Enjoy!


TrackBack

TrackBack URL for this entry:
http://mattberseth.com/blog-mt/mt-tb.fcgi/94

Listed below are links to weblogs that reference Creating an Outlook Navigation Bar using the ListView and Accordion Controls:

» Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion Controls from Rocking with Knowledge
Good Sample Creating an Outlook Navigation Bar using the ListView and Accordion Controls Matt Berseth: [Read More]

» Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion Controls from Rocking with Knowledge
Good Sample Creating an Outlook Navigation Bar using the ListView and Accordion Controls Matt Berseth: [Read More]

» Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion Controls from Rocking with Knowledge
Good Sample Creating an Outlook Navigation Bar using the ListView and Accordion Controls Matt Berseth: [Read More]

Comments


Looks nice but I can't get to the other sections with Javascript turned off.

Posted by: Webdroid on December 16, 2007 01:28 PM

>>Looks nice but I can't get to the other sections with Javascript turned off.


Duh!

This is a great example, thank you !

Posted by: Vish on December 17, 2007 12:46 AM

Hey Matt,
Nice Article

I have done same thing based on Windows XP Theme.

Very nice! And it also works in Opera :-)

Very nice DEMO, I like the simplicity!

nice work.

Posted by: Dan on December 17, 2007 07:51 PM

Hello Matt: I get 'strange' behavior on both Fill and Limit AutoSize enums in IE; however, I also receive different 'strange' behavior in FF. Very 'stange' ;). Thanks for another useful article. Peace... -Dan

Posted by: Bart Czernicki on December 17, 2007 11:51 PM

I did something very similar a couple weeks ago. Couple this with the DragPanelExtender and you have an nice little floating "toolbox".

Posted by: Dan on December 18, 2007 12:25 AM

This is great stuff! Do you have a download of the source code available?

Posted by: Suresh on December 18, 2007 06:23 AM

Hi,
It is very good article. Appreciate your effort.

Thanks,
Suresh M

Would be nice if the AjaxControlToolkit didn't have so many bugs still in it. I hope it gets "finished" to make using controls like this a more viable solution.

Posted by: Stephen on December 18, 2007 03:16 PM

Is there an ASP.NET 2.0 alternative to the list view?

It really works in OPERA!!! :)

Posted by: Lans on December 20, 2007 03:14 AM

It's very nice,Thanks!

Super stuff, just what I was looking for inclusion in a project!

@Rik -

Sorry Rik. Not too many of the examples found around here are going to work with JavaScript turned off.

@Vish -

Do you have a preview or download I could link to?

@Joseph -
I would try the Repeater, its the most flexible.

@Andrei -
Great.

@Joseph -
I agree. Some of the controls could use a bit more polishing. It is great that it is open source but its too bad the ASP.NET community (me included) has contributed more to it. Then maybe some of these issues would go away

@Dan -
You can follow the download link at the top of the post to get the source code.

Nice example ..

Posted by: arthurlu on December 25, 2007 08:11 PM

so good

Posted by: Anonymous on December 29, 2007 05:17 AM

good article.thanks

Posted by: Gabriel Braun on January 19, 2008 08:55 AM

"allows you to provide multiple panes of content and display them one at a time" Is possible to open more than one at a time, causing grow/shrink control?

Also is it possible to resize individual panes?

Posted by: Mutlyp on January 23, 2008 12:16 PM

Great post I just ask you to do one thing that I can not find anywhere on the net. ANYWHERE!
Where you have Mail, Notes and Contacts (Let's call those Categories) and then inside each Category you have the items for that category. Like the one shown on the page; you have the Mail "Category" opened and inside you show the "Items" for Mail like mail, Inbox, Outbox.....

All you have to do is make the Categories be databound to a databse table. Then when user clicks on Mail the categoryID is used as a filter to show the Items (Mailbox, Inbox, Drafts....)

Like I said I CAN NOT FIND ONE example like the one I describe anywhere on the net.
PLEASE HELP
Thanks

good!!

Hi
I like this http://mattberseth2.com/outlook_navbar/
very much
is that a way to reproduce this just using JavaScript or JQuery ?
a "conventional" way ...

Posted by: Nitin Badole on February 8, 2008 07:51 AM

Hello Matt,

I regularly read your blog. I'm also impressed by the screen shots you post in your blog.

I wonder which tool you are using for these neat captures?

Regards,
Nitin

Posted by: PoulBao on February 13, 2008 08:11 AM

Like it very much!

Posted by: Louie on February 19, 2008 10:45 PM

Hi,
very nice post I'll be using this for my project.
I'm just think will it be possible for you to post a outlook navbar that is dynamic and hierarchical up to 3 levels.

I would really appreciate it. thanks.

Posted by: Huong on April 3, 2008 10:58 PM

That's great sample. As you said, your colleague wanted to show right pane' content with selecting subcategory. Could you show me how to set event to each subcategory? When event is called, the corresponding information will be showed on the right pane. I'm a newer. I'd appreciate it. Thanks

Posted by: vytheeswaran on April 11, 2008 01:01 AM

Anything similar in winforms will be very helpfull

Wooow..thanks for sharing.
This is very helpfull.

Posted by: Zubin on April 18, 2008 08:32 AM

You have great stuff out here!!!

My question on the article "Creating an Outlook Navigation Bar using the ListView and Accordion Controls" is

Is it possible to retrive a tree view structure in the accordian control from database.

Thanks

Posted by: Scott on May 2, 2008 12:19 PM

Matt:

Great blog - How did you happen to get rid of the bullets on each list item within the list view?

great blog.it is very nice..thanks..

Posted by: Neil on July 22, 2008 04:32 PM

Fantastic demo. Cool!

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Sponsor

Recent Comments

  • Neil wrote: Fantastic demo. Cool!...
  • hekimboard wrote: great blog.it is very nice..thanks.....
  • Scott wrote: Matt: Great blog - How did you happen to get rid of the bullets on each list item within the list v...
  • Zubin wrote: You have great stuff out here!!! My question on the article "Creating an Outlook Navigation Bar usi...
  • Reyza wrote: Wooow..thanks for sharing. This is very helpfull....
  • vytheeswaran wrote: Anything similar in winforms will be very helpfull...
  • Huong wrote: That's great sample. As you said, your colleague wanted to show right pane' content with selecting s...
  • Louie wrote: Hi, very nice post I'll be using this for my project. I'm just think will it be possible for you to...

Sponsor