Exemplo n.º 1
0
        /// <summary>
        /// Closes the Popup.
        /// </summary>
        private void ClosePopup(string key)
        {
            if (null != OverlayClosed)
            {
                OverlayClosed(this, null);
            }

            if (null != _page)
            {
                _page.BackKeyPress -= new EventHandler <System.ComponentModel.CancelEventArgs>(OnBackKeyPress);
            }

            if (null != _popup)
            {
                _popup.IsOpen = false;
                _popup.Child  = null;
                _popup        = null;
            }

            if (null != _overlayPanel)
            {
                _overlayPanel.Children.Clear();
                _overlayPanel = null;
            }

            if (_overlay != null)
            {
                _overlay.TileSelected -= new QuickJumpGridOverlay.TileSelectedEventHandler(OnOverlayTileSelected);
                _overlay = null;
            }

            if (null != _rootVisual)
            {
                _rootVisual.SizeChanged -= new SizeChangedEventHandler(HandleRootVisualSizeChanged);
            }

            Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    if (!String.IsNullOrEmpty(key))
                    {
                        _itemsControlHelper.ScrollHost.ScrollToVerticalOffset(this.Items.IndexOf(key));
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("ScrollToVerticalOffset Exception: {0}", ex);
                }
            });

            IsOverlayOpen = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens the Popup.
        /// </summary>
        /// <param name="position">Position to place the Popup.</param>
        private void OpenPopup()
        {
            if (IsOverlayOpen)
            {
                return;
            }
            else
            {
                IsOverlayOpen = true;
            }

            if (null != OverlayOpened)
            {
                OverlayOpened(this, null);
            }

            InitializeRootVisual();

            _overlayPanel = new Grid {
                Background = OverlayBackground
            };

            UpdateOverlayPlacement();

            if (_overlay == null)
            {
                _overlay               = new QuickJumpGridOverlay(this);
                _overlay.ItemsSource   = _quickJumpLookup;
                _overlay.TileSelected += new QuickJumpGridOverlay.TileSelectedEventHandler(OnOverlayTileSelected);
            }

            _overlayPanel.Children.Add(_overlay);

            _popup = new Popup {
                Child = _overlayPanel
            };

            if (null != _rootVisual)
            {
                _rootVisual.SizeChanged += new SizeChangedEventHandler(HandleRootVisualSizeChanged);
            }

            if (null != _page)
            {
                _page.BackKeyPress += new EventHandler <System.ComponentModel.CancelEventArgs>(OnBackKeyPress);
            }

            _popup.InvokeOnLayoutUpdated(() =>
            {
                _overlay.Show();
            });
            _popup.IsOpen = true;
        }