예제 #1
0
        /// <summary>
        /// Construct an instance of the MainPage view
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            // Setup custom strings to replace some of PivotViewer's default strings (comment this line to use all defaults)
            System.Windows.Pivot.PivotViewer.SetResourceManager(SampleLocalizedStrings.ResourceManager);

            // Load the initial collection
            string initialCollectionUri;

            if (!App.Current.Host.InitParams.TryGetValue("initialCollectionUri", out initialCollectionUri))
            {
                // Otherwise use the default startup collection
                initialCollectionUri = s_defaultStartupCollectionUri.ToString();
            }
            PivotViewer.LoadCollection(initialCollectionUri, string.Empty);

            PivotViewer.CollectionLoadingFailed += new EventHandler <CollectionErrorEventArgs>(PivotViewer_CollectionLoadingFailed);

            // Enable the shopping cart (comment this line to disable the shopping cart)
            ShoppingCart.Create(PivotViewer);

            // Enable the travel log (comment this line to disable the travel log)
            TravelLog.Create(PivotViewer, new Uri(initialCollectionUri));
        }
예제 #2
0
        /// <summary>
        /// Create a singleton instance of the TravelLog and connect it to a PivotViewer. Because TravelLog
        /// reads/writes App.Current.Host.NavigationState, there should only be one instance of TravelLog in
        /// an application.
        /// </summary>
        public static void Create(PivotViewer pivotViewer, Uri initialCollectionUri)
        {
            if (s_instance != null)
            {
                throw new InvalidOperationException("TravelLog interacts with the application state, there should only be one instance in an application");
            }

            if (pivotViewer.CollectionUri != null)
            {
                throw new InvalidOperationException("TravelLog should be connected to a PivotViewer before it has loaded a collection");
            }

            s_instance = new TravelLog(pivotViewer, initialCollectionUri);
        }