Tag Archives: Sample Code

Silverlight 5 RC – Getting started with PivotViewer

[Updated 06-SEP-2011 - NEW SAMPLES]

Lovely jubbly! Silverlight 5 RC is here

Documentation

Do download the offline help CHM or use the matching online MSDN documentation which is now available – MSDN PivotViewer class

Next step: I need some sort of “Hello world” PivotViewer application, please…

Hello New World!

Look in the “PivotViewer class” help at the bottom, and/or download my sample. I have uploaded this very basic sample for DOWNLOAD as some people seem to be experiencing problems. If this simple sample doesn’t work then likely there is something wrong with your environment. My environment is W7 64-bit Ultimate, VS2010 Sp1, Sl5 Beta (not uninstalled; I know, bad boy, but I was in a rush ;) and then Sl5 RC. Also quad-core 8GB memory, here is very simple stress test SAMPLE too, feel free to modify it. This simple works when not served from a web server.

It isn’t pretty but that is not the point. If you are having problems then get back to check out why. Happy PivotViewing! I’ll post some better samples in the next few days.

Hello world from SL5 RC PivotViewer!

Hello world from SL5 RC PivotViewer!

Hello OLD World!

Here is a sample mixing some legacy CXML collections from Xpert360 with some Silverlight 5 RC PivotViewer and some styling for you to play with. Again feel free to modify.

DOWNLOAD SOURCECODE

And some screen shots…

PivotViewer sample Silverlight 5 RC CXML style

PivotViewer sample Silverlight 5 RC CXML style

PivotViewer sample Silverlight 5 RC CXML style

PivotViewer sample Silverlight 5 RC CXML style

Adventures with PivotViewer Part 7: Slider control

 

In this post we continue to extend the PivotViewer control by taking programmatic control of the Zoom Slider…

PivotViewer Zoom Slider

Programmatic control of Zoom

We need to use the CustomPivotViewer class code to locate the internal StepLogSliderViewModel control. This slider control has the properties that we are interested in:

PivotViewer Zoom Slider Code 1

PivotViewer Zoom Slider Code 1

Here are some click handlers for buttons to zoom in and out:

PivotViewer Zoom Slider Code 2

PivotViewer Zoom Slider Code 2

You can try out the sample Silverlight application here:
PivotViewer Zoom Slider.

Here is the source code for you to play with, if you find it useful, let us know. We have extended the PivotViewer control in other ways too.

Adventures with PivotViewer Parts 6 – 8 source code ZIP.

This sample project is based upon the PivotViewerSample code that shipped with the control, by default it is here for the August 2010 release:

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\PivotViewer\Aug10\Source\PivotViewerSampleXapCode.zip

Adventures with PivotViewer Part 6: Pimp it sample code

 

So let’s continue where the last post left off and finish the high-level pimping of the PivotViewer control…

If you want to follow along then you need to locate the PivotViewerSample code that shipped with the control. By default it is here for the August 2010 release:

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\PivotViewer\Aug10\Source\PivotViewerSampleXapCode.zip

In the previous post the sample code showed you how to hide the left side Filters Panel and the right side Info Panel. It showed you also how to alter the background to help brand the control’s appearance.

The original code was a bit raw so I have put together a small demo application that wraps the functionality up into the custom PivotViewer class override. The sample allows you to toggle the Visibility of the tiles as well as the filters and information panels.

The custom properties can simply be used as in this sample:

...
if (PivotViewer.TileVisibility == Visibility.Visible)
{
PivotViewer.TileVisibility = Visibility.Collapsed;
}
else
{
PivotViewer.TileVisibility = Visibility.Visible;
}

C# Sample: Hide/Show the collection tiles

And the background can be set to ImageBrush like this:

...
// Main tile view background - ImageBrush
StreamResourceInfo sr = Application.GetResourceStream(new Uri("PimpThePivotViewer;component/Resources/Island.jpg", UriKind.Relative));
BitmapImage bmp = new BitmapImage();
bmp.SetSource(sr.Stream);
PivotViewer.GridBackground = new ImageBrush() { ImageSource = bmp };
sr.Stream.Close();

C# Sample: ImageBrush

The sample has a button to toggle the background between:

  • SolidColorBrush = Colors.Black
  • SolidColorBrush = Colors.Transparent
  • RadialGradientBrush
  • LinearGradientBrush
  • ImageBrush

    You can try out the sample Silverlight application here:
    Pimp-the-PivotViewer

    Here is the source code for you to play with, if you find it useful, let us know. We have extended the PivotViewer control in other ways to.

    Pimp-the-PivotViewer source code ZIP.

    Yoga Exercise collection with custom PivotViewer Ypga Theme applied

    PivotViewer Yoga Theme

  • Adventures with PivotViewer Part 4: Augmented PDC10 reality – pivot the agenda

    [News: the collection has been updated with links to the online session content...]

    Microsoft PDC10 is upon us…

    I was a little surprised that the Microsoft PDC team have not published a PivotViewer collection containing the agenda. We have already published a SQLBits 7 agenda and thought why not give PDC10 the same treatment.

    So we did:
    PDC10 agenda collection

    Doing this gets easier and faster every time. That was a lot better experience than earlier attempts.

    PDC10 Agenda in Pivot
    PDC10 Agenda in themed PivotViewer

    If you want to host the collection yourself or access and experiment with it locally using the Pivot application then feel free to do so. We hope it is a useful augmentation to your PDC10 experience. The ZIP contains copies of the dynamically created tiles and an Excel spreadsheet to match the static collection.
    PDC2010.zip

    Have fun!

    Update, very simple PivotViewer client Silverlight 4 application to run with the collection deployed at http://localhost/PDC2010/PDC2010.cxml (I am using the latest Aug-2010 version of PivotViewer and the latest Sep-2010 Silverlight 4).
    Simplest of sample client

    Adventures with PivotViewer – Part 3 Localization

    You want to skin your PivotViewer controls but you also need to localize them for your users. The download files contain a full set of resource strings as contained in the assembly ‘System.Windows.Pivot.StringResources’ (1.0.6079.0).

    You can override the PivotViewer ResourceManager using the PivotViewer.SetResourceManager() API method to set the external ResourceManager.

    [UPDATE] The documentation has moved to: SetResourceManager and the PivotViewer API.

    [C#]
    System.Windows.Pivot.PivotViewer.SetResourceManager(SampleLocalizedStrings
    .ResourceManager);

    The PivotViewer control is globalization aware and even custom date formats, such as those shown in Graph View when drilling into DateTime categories, are defined in the resource files:
    Silverlight Pivot Control Release Notes: Localization and Globalization

    You can localize your PivotViewer application in the same manner as any other Silverlight application. Instructions for creating satellite assemblies can be found here:
    How to: Add Resources to a Silverlight-based Application

    The collection of resource files includes the following languages for a start:
    French / Francaise : fr
    German / Deutsch : de
    Japanese / 日本語 : ja
    Chinese (traditional) / 中文 : zh-CN
    Russian / Русский язык : ru

    e.g. Russian: ru
    CardinalitySortLabel=(количество)
    ClearAllFiltersButton=Убрать сортировку
    CustomFilterPrompt=Что ищем?
    See blog post: Как использовать PivotViewer для Silverlight в реальном проекте (часть I)
    … and sample collection: Главная – Рецензии
    Notice that Microsoft folks did not do a full translation, notice the ‘(no info)’ …

    We can make this a community effort. If you like what you see than pass back corrections and additonal translations and I will post them here. If there is enough interest perhaps we can place the resource files on CodePlex.

    [UPDATE] The full set of string resources finally got published by Microsoft here: Pivot_Internal_StringResources_Resources

    Enjoy!

    Download the resource files: PVSampleResx.zip