none
Using PivotViewer 2 and changing CxmlCollectionSource with cxml files.

    General discussion

  • Hi,

    I'm trying to convert a project from  sl4/pv1 to sl5/pv2 and used to change the cxml file on a button click. The new version loads the cxml but doesn't always display images. If I click on a filter the images display properly . The first display always works.

    TIA

    John

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Windows.Controls.Pivot;

    namespace PivotSample
    {
    public partial class ArtGallery : UserControl
    {
    //private string CXML_PATH;
    string CXML_PATH;
    CxmlCollectionSource _cxml;

    public ArtGallery(int collectiontype)
    {
    InitializeComponent();
    Viewer.Loaded += new RoutedEventHandler(pvViewer_Loaded);

    if (collectiontype == 1)
    {

    CXML_PATH = "http://www.gtz.com/Pivots/MRG/mrgCollection0.cxml";
    }
    else
    if (collectiontype == 101)
    {
    CXML_PATH = "http://www.gtz.com/Pivots/Nina/NinaCollection1/NinaCollection1.cxml";

    }
    else
    if (collectiontype == 201)
    CXML_PATH = "http://www.gtz.com/Pivots/MRGTest/Kiosk1.cxml";
    }

    }

    void pvViewer_Loaded(object sender, RoutedEventArgs e)

    _cxml = new CxmlCollectionSource(new Uri(CXML_PATH, UriKind.Absolute));
    _cxml.StateChanged += new EventHandler<CxmlCollectionStateChangedEventArgs>(_cxml_StateChanged);
    }

    void _cxml_StateChanged(object sender, CxmlCollectionStateChangedEventArgs e)
    {

    if (e.NewState == CxmlCollectionState.Loaded)
    {
    Viewer.PivotProperties = _cxml.ItemProperties.ToList();
    Viewer.ItemTemplates = _cxml.ItemTemplates;
    Viewer.ItemsSource = _cxml.Items;

    }
    }

    // from old pivotviewer
    // OpenLink(args.Link.ToString());
    //}

    /// <summary>
    /// Handle double-clicks on collection items
    /// </summary>


    /// <summary>
    /// Open a URI to either a collection or a web page
    /// </summary>

    //Mar 2012
    // not needed
    //private void OpenLink(string linkUri)
    //{
    // if (linkUri.Contains(".cxml"))
    // {
    // // Link points to a collection file, open it in place
    // // LoadCollection(linkUri);
    // }
    // else
    // {
    // // Link points to a normal web page. Open it in a new tab.
    // HtmlPage.Window.Navigate(new Uri(linkUri, UriKind.RelativeOrAbsolute), "PivotViewerSampleTargetFrame");
    // }
    //}

    /// <summary>
    /// Helper to load a collection from a Uri that may contain a viewerState fragment
    /// </summary>
    // private void LoadCollection(string collectionUri)
    // {
    // string baseCollectionUri;
    // string viewerState;
    // BreakupCollectionUri(collectionUri, out baseCollectionUri, out viewerState);
    // PivotViewer.LoadCollection(baseCollectionUri, viewerState);
    // }
    //private void BreakupCollectionUri(string collectionUri, out string baseCollectionUri, out string viewerState)
    //{
    // string linkUriString = collectionUri;
    // string[] linkParts = linkUriString.Split(new char[] { '#' });
    // baseCollectionUri = linkParts[0];
    // viewerState = (linkParts.Length > 1) ? linkParts[1] : string.Empty;
    //}


    //
    }
    }

    Friday, March 02, 2012 3:09 PM

All replies