예제 #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            //var sampleDataGroups = SampleDataSource.GetGroups((String)navigationParameter);

            CollectionViewModel ctx = new CollectionViewModel();

            IList<CollectionViewModel> collectionList = ctx.GetAllCollections();
            this.DefaultViewModel["Items"] = collectionList;
        }
        /// <summary>
        /// Creates a popup with sort options for the detail page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a new popup
            Popup popUp = new Popup();
            popUp.IsLightDismissEnabled = true;

            // Create a new stack panel
            StackPanel panel = new StackPanel();
            panel.Background = bottomAppBar.Background;
            panel.Height = 80;
            panel.Width = 180;

            // Create buttons to add to collections

            CollectionViewModel ctx = new CollectionViewModel();

            // Returns list of collections
            IList<CollectionViewModel> collectionList = ctx.GetAllCollections();


            // Iterates through each collection and creates a list - this could get messy if there are
            // a lot of collections. Look to creating a drop-down list
            foreach (var co in collectionList)
            {
                Button byAuthorButton = new Button();
                byAuthorButton.Content = co.Title;
                byAuthorButton.Name = co.Id.ToString();
                byAuthorButton.Style = (Style)App.Current.Resources["TextButtonStyle"];
                byAuthorButton.Margin = new Thickness(20, 5, 20, 5);
                byAuthorButton.Click += SortButton_Click;
                panel.Children.Add(byAuthorButton);

            }
            popUp.Child = panel;
            popUp.HorizontalOffset = Window.Current.CoreWindow.Bounds.Right - panel.Width - 4;
            popUp.VerticalOffset = Window.Current.CoreWindow.Bounds.Bottom - bottomAppBar.ActualHeight - panel.Height - 4;
            popUp.IsOpen = true;
        }