Silverlight 5 Hosting :: Simple Sample PivotViewer App in Silverlight 5

I’ve been hoping to share a super simple sample app to showcase PivotViewer in Silverlight 5. I hope this walk through is something you will find useful!

First, let’s take care of the pre-requisites:

  • Install Visual Studio 2010 SP1:

  • Notes for the RC of Silverlight 5:

  • Download and install the Silverlight 5 Runtime and Tools for Visual Studio using the links on that page.

Once you get the pre-reqs, create a new Silverlight application. If you haven’t done this much before, here is a handy link:

  • How to create a Silverlight project from scratch (replace 4s for 5s as appropriate):

Now, let’s add a PivotViewer. I want to view people by age and birthday. You will need to edit the MainPage.xaml and MainPage.xaml.cs files and add a reference to System.Windows.Controls.Pivot.


 <UserControl x:Class="Birthdays.MainPage"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <pv:PivotViewer x:Name="pivotviewer" ItemsSource="{Binding}">
                <pv:PivotViewerStringProperty Id="Name" Options="CanFilter" DisplayName="Name" Binding="{Binding Name}" />
                <pv:PivotViewerNumericProperty Id="Age" Options="CanFilter" DisplayName="Age" Binding="{Binding Age}" />
                <pv:PivotViewerDateTimeProperty Id="Birthday" Options="CanFilter" DisplayName="Birthday" Binding="{Binding Birthday}" />
                    <Border Width="200" Height="200" Background="DarkSlateBlue">
                        <TextBlock Text="{Binding Name}" FontSize="30" FontFamily="Georgia" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />


using System;
using System.Collections.Generic;
using System.Windows.Controls;

namespace Birthdays
    public partial class MainPage : UserControl
        public MainPage()

            List<Person> birthdayBook = new List<Person>();
            birthdayBook.Add(new Person("Brad", 25, new DateTime(1986, 5, 9)));
            birthdayBook.Add(new Person("Janet", 12, new DateTime(1998, 12, 3)));
            birthdayBook.Add(new Person("Rocky", 43, new DateTime(1968, 7, 17)));
            birthdayBook.Add(new Person("Magenta", 21, new DateTime(1990, 2, 21)));

            pivotviewer.DataContext = birthdayBook;

        public class Person
            public string Name { get; set; }
            public int Age { get; set; }
            public DateTime? Birthday { get; set; }

            public Person(string name, int age, DateTime? birthday)
                this.Name = name;
                this.Age = age;
                this.Birthday = birthday;

When I compile the code above, I get the sample PivotViewer collection I snapshotted. It should be incredibly easy. You can bind to any data type, you can use whatever object definitions make sense for your data.

Comments are closed.


Cheap Reseller Hosting

Best Blog Hosting Provider

Best European ASP.NET 4.0 Hosting Provider