Panorama and Pivot controls for Windows Phone developers

Apps in Windows Phone 7 make it easy to explore and experience information thanks to two similar navigation controls: panorama and pivot controls. We’ve made it easy for developers to build applications with these experiences by putting these Silverlight controls and associated tooling in the next release of the free developer tools (didn’t make the beta).

The controls are simple & easy to use, but I’ve seen enough rumbling on forums to know that developers are anxious to learn more about their capabilities.

9/16/2010 Update: These controls are now in the official Windows Phone developer tools (quick post by me, but you really want to download here).

In this post I’m going to introduce these controls and how they appear from a simple API & XAML perspective.


Panorama control inside of the Visual Studio design surface for the Windows Phone 7.

Learning about the native experience

Since phones are just beginning to trickle out, if you’d like to see what the built-in applications look like, there’s some multimedia up at WindowsPhone7.com.

A panorama powers the people, music + videos, parts of Office, and more. Many of these have a large background and can be explored by panning and flicking between items. When you’re at one item, you will be able to see a little bit of the next item as well – a hint that there’s more to be explored. When you reach the far side of the panorama, you can keep going to wrap around to the beginning again, saving time.

A pivot control powers the e-mail and calendar pages, operating systems, etc. The top of the pivot control shows the headers for all the different items, and you can swipe and pan between the pages. Just like panorama, the control wraps infinitely – so when you reach the final item, instead of having to flick all the way back to the first item, you can just flick once more.

Key Features

Both of the controls are lightweight enough to have great performance, while visually engaging and responsive to touch. Some features:

  • Simple XAML and application programming interfaces
  • Standard items controls that feels natural to developers, individual items are built from PanoramaItem and PivotItem content controls
  • Complete data binding support, content template properties and item container styles
  • Automatic support for light and dark phone themes
  • Built-in touch navigation: flicks move quickly, while panning past a threshold and releasing the touch will snap to the next item
  • Beautiful easing animations for sliding during navigation
  • Extensibility offered through events, visual states, and the ability to re-template
  • Great tooling comes standard, including app and page templates

So let’s take a look at the two controls!

Panorama


A visual depiction of the actual contents of the panorama control stretching beyond the physical size of the screen.

From the UI design and interaction guide for Windows Phone 7, the UX folks say:

Unlike standard applications that are designed to fit within the confines of the phone screen, these applications offer a unique way to view controls, data, and services by using a long horizontal canvas that extends beyond the confines of the screen.

Elements of a panoramic application serve as the starting point for more detailed experiences.

The background image is the lowest layer and is meant to give the panorama its rich magazine-like feel. Usually a full-bleed image, the background is potentially the most visual part of the application.

As all things in design go, what is not on the screen is as important as what is there: the control has a lot of empty space that helps keep the eye focused on the rich experience and data.

Panorama XAML

The Panorama control is placed on pages of your application and accepts a title and a background. Panorama sections are defined by PanoramaItem controls, and each has a header. The Title and Header are easiest to use when you’re just inserting text, but they also have associated HeaderTemplate and TitleTemplate dependency properties for data binding scenarios.

<controls:Panorama
        Title="my panorama">
        <controls:Panorama.Background>
            <ImageBrush ImageSource="MyWidescreenBackground.jpg"/>
        </controls:Panorama.Background>

        <controls:PanoramaItem
            Header="first item">

            <StackPanel>
                <TextBlock
                    Text="This is a simple sample ..."
                    Style="{StaticResource PhoneTextLargeStyle}"
                    TextWrapping="Wrap"/>
            </StackPanel>

      </controls:PanoramaItem>

      <!-- insert other panorama items here in a real app -->
</controls:Panorama>

About wide horizontal sections

The panorama allows for special sections that are wider than the screen. Built-in phone hubs often use this for sets of thumbnails, albums, and other displays. If this is the appropriate effect you want for a section, make sure that the PanoramaItem declares that intent by setting the orientation to horizontal. Here’s what the minimized XAML looks like:

<controls:PanoramaItem Orientation="Horizontal">
    <!-- insert thumbnails and other goods here -->
</controls:PanoramaItem>

Panorama APIs

The key application programming interface for the Panorama builds on top of ItemsControl: so you get the standard items control properties (Items, ItemsSource, etc.), but also additional properties for setting the header, title, and reacting to the currently selected items by the user.

Microsoft.Phone.Controls.Panorama

Dependency Properties
  • DefaultItem

    Sets the default item that moves into display. Allows your application to store the user’s most recently used panorama item to return to it later, just like the native operating system’s built-in hubs.

  • HeaderTemplate
  • SelectedIndex
  • SelectedItem
  • Title
  • TitleTemplate
Events
  • SelectionChanged

    Allows the developer to hook up to selection changes (navigations from one panorama item to another).

Microsoft.Phone.Controls.PanoramaItem

Dependency Properties
  • Header
  • HeaderTemplate
  • Orientation

    Setting the orientation to Horizontal will allow the item to be of a larger size than the control so that the user can pan and navigate within it. By default, this property is Vertical, which means that panning or flicking should instead bring you to the next panorama section.

Pivot control

The pivot control is a lot like the a tab control, but designed specifically for the phone and touch interaction. The entire pivot control (often the size of the screen and the root element on a page) can be panned, flicked, and manipulated – it’s not just about those headers (though those can be touched to navigate, too).

A simple pivot sample application running in the emulator. Notice that the phone’s theme in the emulator has been set to the light theme, and the control just works without the developer having to do anything.

From the design guidelines document:

A pivot control provides a quick way to manage views or pages within the application. This control can be used for filtering large datasets, viewing multiple data sets, or switching application views. The control places individual views horizontally next to each other, and manages the left and right navigation. Flicking or panning horizontally on the page cycles the pivot functionality.

Pivot XAML

<controls:Pivot Title="MY APPLICATION">

    <controls:PivotItem
        Header="welcome">

        <StackPanel
            Margin="20">
            <TextBlock
                TextWrapping="Wrap"
                Text=" This is a simple sample ..."
                Style="{StaticResource PhoneTextLargeStyle}">
            </TextBlock>
        </StackPanel>

    </controls:PivotItem>

    <!-- other pivot items -->
</controls:Pivot>

Pivot APIs

Microsoft.Phone.Controls.Pivot

Dependency Properties
  • HeaderTemplate

    A single data template that can be used for all headers in data binding scenarios.

  • SelectedIndex
  • SelectedItem
  • Title
  • TitleTemplate
Events
  • LoadedPivotItem
  • LoadingPivotItem
  • SelectionChanged
  • UnloadedPivotItem
  • UnloadingPivotItem

Microsoft.Phone.Controls.PivotItem

Pivot item is a simple content control and does not have any other special properties.

Visual Studio & Expression Blend Tooling

The tools are fully integrated with the design tools: if you click on an item in XAML, that item will become the one active in the design surface. There’s also an easy way to add additional items, well-defined control property editing, and so this all makes it really easy to get started building immersive apps.

Start with a complete application template

You can start off with an app powered by a panorama or pivot control: File > New Project has built-in templates for these apps.

Add New Pages

When you want to add a new Windows Phone page to your app, you can also add one that’s all ready to go with either a panoramic experience or pivot control, too. Just go to the Project menu and select Add New Item:

This makes it really easy to build out applications as quick as you can click.

Blend Assets

If you need to add either control to an existing app, in Blend you’ll find them in the Assets window, so they’re right where you’d expect to find them when you need ‘em.

Easy property editing

Key properties are easily accessible in the property editor. In this screen capture, you can see how easy it is to change an item to Horizontal mode, or to change the Header property:

Right-click, add new panorama item or pivot item

Integrated into the design surface you can also add extra items to the controls by right-clicking.

 

Visual Studio design surface

 

Expression Blend

Other notes

The controls can be found in the Microsoft.Phone.Controls namespace of the Microsoft.Phone.Controls.dll assembly, installed with the official Windows Phone Developer Tools.

As we get closer to launch, I’m sure we will have a good list of caveats and suggestions for the controls. Here are a few things that I had in mind that I wanted to share ahead of time, in case you are designing your application experiences and pages today.

Exposing scrolling data

If you look at applications on the phone such as Mail, you’ll often see that the Pivot control is used to filter and sort data. So when you move to the “unread” pivot item, you have unread mail items; flicking your finger again, you’ll get to “flagged”, listing the messages that you have flagged.

You could easily have hundreds of items in a single pivot item.

If you want to enable scrolling, you must either use a scrolling control like ListBox, or add a ScrollViewer to the pivot or panorama item. Scrolling is not enabled by default. This helps ensure that items are always sized to the parent container like you’d expect in the Silverlight-powered layout system.

Here’s how to add a scroll viewer or list box to a pivot item. Note that you’ll only want to offer a vertical scrolling experience, since horizontal manipulations (pan or flick) are part of the navigation experience with these two controls.

<controls:Pivot Grid.Row="0"
                x:Name="Pivot1"
                Title="INBOX">
    <controls:PivotItem
        Header="all">
        <ListBox
            ItemTemplate="{StaticResource MyMailDataTemplate}"
            ItemsSource="{Binding Items}">
        </ListBox>
    </controls:PivotItem>

    <controls:PivotItem
        Header="unread">
        <ScrollViewer
            ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <!-- Some large vertical list here -->
        </ScrollViewer>
    </controls:PivotItem>
</controls:Pivot>

The example uses data binding to the data context, as well as custom-defined data templates from the application’s resources, so don’t just paste it into your app… but you get the idea I hope.

Items control API

These controls do both derive from ItemsControl, but they do have subtle differences.

Both controls

  • Items can be added in XAML
  • Items can be added in code, Items.Add(new PivotItem(…)) or Items.Add(new PanoramaItem(…))
  • ItemsSource can be used for data binding
  • Do not support alternative types of items: Pivot controls must use PivotItem, Panorama must have PanoramaItem

Differences

  • Panorama exposes a DefaultItem property
  • SelectedIndex and SelectedItem are settable in Pivot but not in Panorama

Migration

There are a number of alternative implementations of these controls out there, so for release, we’ll be working to blog guidance on migrating from one of those other experiences to these controls if you would like to. Note that the http://phone.codeplex.com/ controls *are not official* and you should probably consider using these instead now that the tools are public.

  • Pingback: For Developers: Windows Phone 7 panorama and pivot control coming next beta, see the tutorial now

  • http://www.pocketmax.net pocketmax

    Hi Jeff,

    Just what we needed to know. Are there no plans for a release candidate with this ahead of final release so we can provide feedback?

    many thanks
    Bruce

  • Pingback: Looking ahead: Panorama and Pivot controls for Windows Phone developers | GoPDA Windows Mobile(Windows Phone) Blog

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Bruce,
    I don’t think we have a good mechanism for getting these out ahead of the next release.

  • http://www.mdtadesign.co.uk Martin Anderson

    Will it be possible to bind the panorama background image to a resource dictionary resource, like image brush?

    Can you use an image or text, or even both for the panorama title?

    Does the Panorama handle the panorama items opacity lowering as you drag your finger to the next panorama item?

    And one final question, will the panorama control or panorama page support the sliding animation as you transition into the panorama page?

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Martin,
    1. Yes, the example XAML in the post shows the use of an image brush for the background. The Background is just like any other control, so you can use value converters, static resources, data binding, you name it.

    2. The UX guidelines suggest text only, but you could set Title to any user interface element (and/or use the TitleTemplate as part of this) to achieve the desired effect of using UI elements.

    3. No, the panorama control does not do this by default. The opacity lowering experience in other parts of the phone itself are inconsistent and there were technical reasons for this decision as well. It may be possible to do this work in your application however, I will need to check. I don’t have an answer either way on a workaround.

    4. Yes, the panorama at startup will start next to the default item and transition in similar to the native OS.

  • http://www.mdtadesign.co.uk Martin Anderson

    Thank you so much for answering my questions!!!

    I have had a hard time using the codeplex panorama control. I have had to re-template almost all of it, and even then it is still a bit buggy, with sections resetting their contents, and things poping out of nowhere lol!

  • http://www.silvercrux.com Janki

    Now that you are spilled the beans :) , can you spill a little more ? Do you know when it is coming and do you know if other controls are coming too ? (Like Calendar control, Date and Time Pickers etc) ?

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Janki,
    All that I’m sharing today is information about these controls, no timelines or other specifics, sorry.

  • Mick (Sydney, Aus)

    Jeff, good call. This was totally a step in the right direction on these controls. Can I ask for plans on any if the other controls whil I’m here? Date picker? Time picker? List picker? Whilst these haven’t met with the same volume of “interest”, the interest has been consistant since people first saw these controls teased at mix in albert’s talk. Some frustration has been fielded.

  • Pingback: DotNetShoutout

  • Jeff Weber

    Will these controls be configurable to work in landscape mode?

    I’d like to use these controls for my game UI but my game is landscape mode only.

    -Jeff Weber
    http://www.farseergames.com

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Jeff Weber,
    Pivot works great automatically on pages that are landscape and portrait.

    Panorama technically works great in both, but officially the Windows Phone UX guidelines suggest only using Panorama in portrait screens… but it makes sense for a game this would be cool.

  • Pingback: The Morning Brew - Chris Alcock » The Morning Brew #663

  • Vikram

    Very Nice article and informative too.About Panorama, I just want to know, I mean got in my mind, Is there any events get fire moving from One item to another,I mean if I wish to implement something either while moving from One item to Two item or on load of item two?

  • Pingback: Preview of the Panorama and Pivot Controls in WP7 | Kotan Code 枯淡コード

  • Will

    Nice to get a bit more info about these controls, thanks.

    Just a quick question, how do App Bars work with these controls?

    E.g. I want a few pages within a pivot control that each had different app bars (so using it like a tab mechanism).

    Also, I know you’re not giving dates away but are these likely to come out before the launch of the phone or will it be after?

    Thanks

  • Pingback: Noticias sobre los controles Pivot y Panorama | Windows Phone 7 en Español

  • Stephen

    Thanks (and about time)!

  • http://www.richschoenrock.com Rich S

    This is awesome…I am so excited to get the actual bits when they’re released!

  • Rob Cannon

    Will there be analogous controls released for the core (web/desktop) version of Silverlight?

    Also, the control name Pivot is an unfortunate choice since there is another Silverlight Pivot control based on the DeepZoom technology. It makes searching for information about this control hard.

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Rob,
    I’m not sure what the desktop story is, since these controls are completely based on touch manipulations that just aren’t on most machines out there today.

    The pivot control name is confusing, however do note that the deep zome one is called PivotViewer, if that makes searching any easier, as you can add a -PivotViewer clause to any search.

  • Jon

    Jeff,

    Hopefully this isn’t a silly question, but what is the syntax in C# for navigating from one index to another? Say I’m on Pivot 1 and I press a button to take me to Pivot 3. What does the syntax look like in the code behind? Thanks!

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Jon,
    You could change the SelectedIndex property for Pivot, though I think most of these controls should really leave any navigation up to the user and their touch gestures.

  • Pingback: Windows Phone 7 – Platform « Critical Development

  • Pingback: Panorama and Pivot controls for Windows Phone developers | wpseven

  • Pingback: August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7 - ScottGu's Blog

  • Pingback: Revue du web du 6 septembre | virtew

  • Ed Scott

    Jeff, I got the beta, but I really cant find the pivot template. I have VS 2010 pro using the beta. am I missing something else?

    Thanks, Ed

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Ed,
    As the post states, the controls and templates are not in the beta, they will be in the release version of the tools. This was a preliminary post.

  • Pingback: La typographie dans Metro « Sebastien Mornas's Blog

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    And to insert a quick “break” into the comments stream: today, 9/16/2010, the final tools went RTM/public, so all comments now likely will feature the actual, released controls. Everything in this post is still valid btw.

  • Jimmy

    I’m having an issue with the RTM version. When databinding, it’s not possible to access the controls used in the HeaderTemplate or ItemTemplate.

    In the code above, it’s not possible to access the ClientListBox ListBox from codebehind.

    Am I missing something here?

    Thanks,
    Jimmy

  • Jimmy

    Darn, the code was remove from my comment. Please contact me for the code if needed.

    Thanks,
    Jimmy

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Jimmy,
    Typically related controls are created only when the items presenter needs them, so they won’t immediately be available when binding first happens.

  • http://jaykimble.net Jay Kimble

    Jeff,

    There is one scenario where the developer really needs to be able to set the SelectedIndex of the Panorama

    (I’m preparing demos for Tallahassee CodeCamp this month and encountered it). I’m doing a demo showing the user how to deal with tombstoning. When the user comes back to the screen if I don’t do something they will not end up on the right page/tab of the panorama. What I did was I save the SelectedIndex and then use it one restore to set the DefaultItem to the right item in the Items Collection using the SelectedIndex. It’s not optimal, but it works.

    The reason I say not optimal is that the header text at the top is a little different when the user comes back in (it’s not offset to the correct position), BUT like I said it works and it’s not too bad.

  • http://www.jeff.wilcox.name/ Jeff Wilcox

    @Jay,
    Thanks, I’ve passed your comment along to the Panorama folks.

  • Pingback: Windows Phone 7 Developer Launch | Code Prone

  • Pingback: Mi Windows Phone » Noticias sobre los controles Pivot y Panorama

  • Pingback: Cum dezvolt aplicatii pentru Windows Phone 7? - Android Romania

  • http://twitter.com/ItsRandom Richard Trammell

    On developing WP7 Apps and using Expression Blend and/or Visual Studio, which app is preferred and especially for a novice developer? Are they both needed for WP7 development or can you use one or the other? I’m just a little confused as to where to start.

    Thanks

  • Anonymous

    For the most basic app, I’d recommend starting with Visual Studio express
    edition that’s free – and focus on just the very basics while learning the
    way to code and build the app up. Then, try Blend once comfortable. Pick up
    a phone dev book and it should have good tutorials.