예제 #1
0
        private void itemContextMenu_Opened(object sender, System.Windows.RoutedEventArgs e)
        {
            var menu = sender as ContextMenu;
            IContentViewModel content = menu.DataContext as IContentViewModel;
            if (content != null)
            {
                var wrapper = new AwfulContextMenu();
                var isOpen = content.OnContextMenuOpening("item", wrapper, this, this.Progress);
                if (isOpen)
                    wrapper.ToContextMenu(menu);

                menu.IsOpen = isOpen;
            }
        }
예제 #2
0
        private void rateThreadButton_Click(object sender, RoutedEventArgs e)
        {
            ThreadDataItem thread = this.itemListView.SelectedItem as ThreadDataItem;
            if (thread == null)
                throw new InvalidOperationException("Expected selected item to be data type: thread.");

            Button button = sender as Button;
            AwfulContextMenu menu = new AwfulContextMenu();
            var hasRate = thread.OnContextMenuOpening("rate", menu, this, this.progress);
            
            if (!hasRate)
                throw new InvalidOperationException("Expected thread to generate rate context menu.");

            MenuFlyout flyout = menu.ToMenuFlyout();
            button.Flyout = flyout;
            flyout.ShowAt(button);
        }
예제 #3
0
        private async void OnItemRightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            FrameworkElement element = sender as FrameworkElement;
            IContentViewModel content = element.DataContext as IContentViewModel;
            if(content != null)
            {
                // detach the appbar opening event.
                this.BottomAppBar.Opened -= OnBottomAppBarOpened;

                AwfulContextMenu menu = new AwfulContextMenu();
                var hasMenu = await content.OnContextMenuOpeningAsync("item", menu, this, this.progress);

                if (hasMenu)
                {
                    var itemContextBar = menu.ToAppBarButtonContainer(true);
                    EventHandler<object> opened = null;
                    opened = new EventHandler<object>((obj, args) =>
                    {
                        this.BottomAppBar.Opened -= opened;
                        this.BottomAppBar.Opened += OnBottomAppBarOpened;
                    });

                    this.SelectBottomAppBar(itemContextBar);
                    this.BottomAppBar.Opened += opened;
                    this.BottomAppBar.IsOpen = true;
                }

                else
                {
                    this.BottomAppBar.Opened += OnBottomAppBarOpened;
                    this.BottomAppBar.IsOpen = false;
                }
            }
        }