using System.Collections.Generic;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace VisitedPageSave
{
    public class SaveStatePage : Page
    {
        protected Dictionary<string, object> pageState;

        static protected Dictionary<int, Dictionary<string, object>> pages =
                                new Dictionary<int, Dictionary<string, object>>();

        protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            if (args.NavigationMode == NavigationMode.New)
            {
                // Tworzenie klucza słownika
                int pageKey = this.Frame.BackStackDepth;

                // Usunięcie klucza strony i wyższych kluczy stron
                for (int key = pageKey; pages.Remove(key); key++) ;

                // Utworzenie nowego słownika stanu strony i zapisanie go
                pageState = new Dictionary<string, object>();
                pages.Add(pageKey, pageState);
            }

            base.OnNavigatedTo(args);
        }
    }
}
