DCSIMG
Silverlight PivotViewer – Add Collection To Your Silverlight Application - Shai Raiten

Shai Raiten

 Subscribe

Silverlight PivotViewer – Add Collection To Your Silverlight Application

Silverlight PivotViewer – Add Collection To Your Silverlight Application

In my last post Silverlight Pivotviewer – The Full Guide was about Silverlight PivotViewer introduction and how to create your own collection to group large amount of data.image

In this post I’ll show how to add your Pivot Collection to your Silverlight Application.

image

Gettings Started

1. Create new Silverlight Application

2. Add reference to “System.Windows.Pivot.dll” located under
C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\PivotViewer\Jun10\Bin\

3. Add Pivot name space to your Xaml file –>
xmlns:pivot="clr-namespace:System.Windows.Pivot;assembly=System.Windows.Pivot"

4. Add Pivot Viewer Control

 <!-- The PivotViewer control -->
<pivot:PivotViewer Name="PivotViewerControl" Grid.Column="0"
                  ItemDoubleClicked="PivotViewerControl_ItemDoubleClicked">
</pivot:PivotViewer>
5. Add collection .cxml file and the files folder to your ClientBin (or if you want you can upload all under hosting service).
6. Load collection using this method - PivotViewerControl.LoadCollection(MauritiusCollectionUri, "");
7. I’ve add an event for double clicking on Collection Items, so when you double click and new browser 
will open with the item link.
8. You’re Done! – Download Demo Project

Full Code Example:

private static readonly string MauritiusCollectionUri = "http://localhost:42912/ClientBin/Mauritius.cxml";

public MainPage()
{
    InitializeComponent();
    //Load your collection
    PivotViewerControl.LoadCollection(MauritiusCollectionUri, "");
}

private void OpenLink(string linkUri)
{
    HtmlPage.Window.Navigate(new Uri(linkUri, UriKind.RelativeOrAbsolute), "PivotViewerSampleTargetFrame");
}

//When double clicking an item I want to open a new browser with item link.
private void PivotViewerControl_ItemDoubleClicked(object sender, ItemEventArgs e)
{
    PivotItem piv_item = PivotViewerControl.GetItem(e.ItemId);

    if (!string.IsNullOrWhiteSpace(piv_item.Href))
    {
        PivotViewerControl.CurrentItemId = e.ItemId;
        OpenLink(piv_item.Href);
    }
    else
    {
        MessageBox.Show("No Web Page...");
    }
}

 

Download Demo Project

You want more? Just send me an email and more about Silverlight PivotViewer will arrive.

Comments

d said:

I tried your demo, but I'm getting an XAMLParseException error that element is already the child of another element on InitializeComponent() line of main page.

# July 4, 2010 8:08 PM

Pivot????????????????????????Pivot?????????????????? « ??????????????????????????? said:

Pingback from  Pivot????????????????????????Pivot?????????????????? &laquo;  ???????????????????????????

# July 18, 2010 4:06 AM

Ashish said:

Hi i am getting error "Element is already the child of another element" how to resolve this.

Regards,

Ashish

# August 25, 2010 12:07 PM

gijs de bont said:

your applicatie do'nt start;

Download Demo Project

problems with

xmlns:pivot="clr-namespace:System.Windows.Pivot;assembly=System.Windows.Pivot"

# September 2, 2010 12:48 AM

shair said:

Hi Ashish,

Are you still having problems?

# September 5, 2010 8:36 AM

shair said:

Hi,

Try adding “System.Windows.Pivot.dll” located under

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\PivotViewer\Jun10\Bin\

And make sure you have download - www.microsoft.com/.../details.aspx

# September 5, 2010 8:37 AM

gijs de bont said:

hi

now it is woking on my machine as

localhost/SilverlightApplication1TestPage.aspx

thanks

now I try to impliment it on my site

with regards

gijs de bont

++ p.s.  I installed Visual Studio 2010 Professional on this machine!!!

# September 16, 2010 11:44 AM

gijs de bont said:

hi

we have te problem with

\Error in Silverlight Application Code: 4004

etc etc

Category: ManagedRuntimeError      

Message: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException: AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 37 Position: 30]

  at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)

etc etc

do you have a solution

with regards

gijs de bont

andelst@gijsdebont.info

andelst

# September 22, 2010 2:35 PM

Evangelist Blog said:

&#160; Web Platform Installer (WebPI) download Link Microsoft Web Platform http://www.microsoft.com/web

# November 16, 2010 6:01 PM

Push said:

Thanks for this great article. I was able to implement my collection perfectly. The only weird thing is - once i enter a path for the brand image, I start getting a "Element is already the child of another element" error. I am using the excel collection tool.

# January 14, 2011 11:18 PM

sri said:

I have created the cxml collection and placed in clientbin directory,then i have given the cxml URl to Pivotviewer control, the items not showing.

# February 15, 2011 8:50 AM

guattewak said:

Gonna write here until you answer me to tell me that's the reason why I'm banned I do not get on the chat on Thursday night and now it's Saturday. I want one explanation!

# February 20, 2011 10:19 PM

sugandha said:

hi...its really helpful...thanks alot...m successful making a pivotviewer work in my localhost ...bt can u help me or guide me how can i make it online or host it on server so that others can view it......

# July 7, 2011 11:00 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: