Example #1
0
        /// <summary>
        /// Closes the group popup.
        /// </summary>
        /// <param name="selectedGroup">The selected group.</param>
        /// <param name="raiseEvent">Should the GroupPopupClosing event be raised.</param>
        /// <returns>True if the event was not raised or if it was raised and e.Handled is false.</returns>
        private bool ClosePopup(object selectedGroup, bool raiseEvent)
        {
            if (raiseEvent)
            {
                GroupViewClosingEventArgs args = null;

                SafeRaise.Raise(GroupViewClosing, this, () => { return(args = new GroupViewClosingEventArgs(_itemsControl, selectedGroup)); });

                if (args != null && args.Cancel)
                {
                    return(false);
                }
            }

            if (_groupSelectorPopup != null)
            {
                RestoreSystemState();
                _groupSelectorPopup.IsOpen = false;
                DetachFromPageEvents();
                _groupSelectorPopup.Child = null;
                _border             = null;
                _itemsControl       = null;
                _groupSelectorPopup = null;
            }

            return(true);
        }
        /// <summary>
        /// Closes the group popup.
        /// </summary>
        /// <param name="selectedGroup">The selected group.</param>
        /// <param name="raiseEvent">Should the GroupPopupClosing event be raised.</param>
        /// <returns>True if the event was not raised or if it was raised and e.Handled is false.</returns>
        private bool ClosePopup(object selectedGroup, bool raiseEvent)
        {
            if (raiseEvent)
            {
                GroupViewClosingEventArgs args = null;

                SafeRaise.Raise(GroupViewClosing, this, () => { return args = new GroupViewClosingEventArgs(_itemsControl, selectedGroup); });

                if (args != null && args.Cancel)
                {
                    return false;
                }
            }

            if (_groupSelectorPopup != null)
            {
                RestoreSystemState();
                _groupSelectorPopup.IsOpen = false;
                DetachFromPageEvents();
                _groupSelectorPopup.Child = null;
                _border = null;
                _itemsControl = null;
                _groupSelectorPopup = null;
            }

            return true;
        }
        private void BuildPopup()
        {
            _groupSelectorPopup = new Popup();
            _border = new Border() { Background = new SolidColorBrush(Color.FromArgb(0xa0, 0, 0, 0)) };
            GestureListener listener = GestureService.GetGestureListener(_border);
            listener.GestureBegin += HandleGesture;
            listener.GestureCompleted += HandleGesture;
            listener.DoubleTap += HandleGesture;
            listener.DragCompleted += HandleGesture;
            listener.DragDelta += HandleGesture;
            listener.DragStarted += HandleGesture;
            listener.Flick += HandleGesture;
            listener.Hold += HandleGesture;
            listener.PinchCompleted += HandleGesture;
            listener.PinchDelta += HandleGesture;
            listener.PinchStarted += HandleGesture;
            listener.Tap += HandleGesture;

            _itemsControl = new LongListSelectorItemsControl();
            _itemsControl.ItemTemplate = GroupItemTemplate;
            _itemsControl.ItemsPanel = GroupItemsPanel;
            _itemsControl.ItemsSource = ItemsSource;

            _itemsControl.GroupSelected += itemsControl_GroupSelected;

            _groupSelectorPopup.Child = _border;
            ScrollViewer sv = new ScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled };

            _border.Child = sv;
            sv.Content = _itemsControl;

            SetItemsControlSize();
        }
 private void ClosePopup()
 {
     RestoreSystemState();
     _groupSelectorPopup.IsOpen = false;
     DetachFromPageEvents();
     _groupSelectorPopup.Child = null;
     _border = null;
     _itemsControl = null;
 }
Example #5
0
        private void BuildPopup()
        {
            _groupSelectorPopup         = new Popup();
            _groupSelectorPopup.Opened += popup_Opened;

            // Support the background color jumping through. Note that the
            // alpha channel will be ignored, unless it is a purely transparent
            // value (such as when a user uses Transparent as the background
            // on the control).
            SolidColorBrush background = Background as SolidColorBrush;
            Color           bg         = (Color)Resources["PhoneBackgroundColor"];

            if (background != null &&
                background.Color != null &&
                background.Color.A > 0)
            {
                bg = background.Color;
            }
            _border = new Border
            {
                Background = new SolidColorBrush(
                    Color.FromArgb(0xa0, bg.R, bg.G, bg.B))
            };

            // Prevents touch events from bubbling up for most handlers.
            _border.ManipulationStarted   += ((o, e) => e.Handled = true);
            _border.ManipulationCompleted += ((o, e) => e.Handled = true);
            _border.ManipulationDelta     += ((o, e) => e.Handled = true);

            var gestureHandler = new EventHandler <System.Windows.Input.GestureEventArgs>((o, e) => e.Handled = true);

            _border.Tap       += gestureHandler;
            _border.DoubleTap += gestureHandler;
            _border.Hold      += gestureHandler;
            _borderPadding     = _border.Padding;

            _itemsControl = new LongListSelectorItemsControl();
            _itemsControl.ItemTemplate = GroupItemTemplate;
            _itemsControl.ItemsPanel   = GroupItemsPanel;
            _itemsControl.ItemsSource  = ItemsSource;

            _itemsControl.GroupSelected += itemsControl_GroupSelected;

            _groupSelectorPopup.Child = _border;
            ScrollViewer sv = new ScrollViewer()
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
            };

            _itemsControl.HorizontalAlignment = HorizontalAlignment.Center;
            _itemsControl.Margin = new Thickness(0, 12, 0, 0);
            _border.Child        = sv;
            sv.Content           = _itemsControl;

            SetItemsControlSize();
        }
Example #6
0
        private void BuildPopup()
        {
            _groupSelectorPopup = new Popup();

            var bg = (Color)Resources["PhoneBackgroundColor"];

            _border = new Border
            {
                Background = new SolidColorBrush(
                    Color.FromArgb(0xa0, bg.R, bg.G, bg.B))
            };

            GestureListener listener = GestureService.GetGestureListener(_border);

            listener.GestureBegin     += HandleGesture;
            listener.GestureCompleted += HandleGesture;
            listener.DoubleTap        += HandleGesture;
            listener.DragCompleted    += HandleGesture;
            listener.DragDelta        += HandleGesture;
            listener.DragStarted      += HandleGesture;
            listener.Flick            += HandleGesture;
            listener.Hold             += HandleGesture;
            listener.PinchCompleted   += HandleGesture;
            listener.PinchDelta       += HandleGesture;
            listener.PinchStarted     += HandleGesture;
            listener.Tap += HandleGesture;

            _itemsControl = new LongListSelectorItemsControl();
            _itemsControl.ItemTemplate = GroupItemTemplate;
            _itemsControl.ItemsPanel   = GroupItemsPanel;
            _itemsControl.ItemsSource  = ItemsSource;

            _itemsControl.GroupSelected += itemsControl_GroupSelected;

            _groupSelectorPopup.Child = _border;
            ScrollViewer sv = new ScrollViewer()
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
            };

            _border.Child = sv;
            sv.Content    = _itemsControl;

            SetItemsControlSize();
        }
        private void BuildPopup()
        {
            _groupSelectorPopup = new Popup();
            _groupSelectorPopup.Opened += popup_Opened;

            var bg = (Color)Resources["PhoneBackgroundColor"];
            _border = new Border
            {
                Background = new SolidColorBrush(
                    Color.FromArgb(0xa0, bg.R, bg.G, bg.B))
            };
            
            // Prevents touch events from bubbling up for most handlers.
            _border.ManipulationStarted += ((o, e) => e.Handled = true);
            _border.ManipulationCompleted += ((o, e) => e.Handled = true);
            _border.ManipulationDelta += ((o, e) => e.Handled = true);
            
            var gestureHandler = new EventHandler<System.Windows.Input.GestureEventArgs>((o, e) => e.Handled = true);
            _border.Tap += gestureHandler;
            _border.DoubleTap += gestureHandler;
            _border.Hold += gestureHandler;

            _itemsControl = new LongListSelectorItemsControl();
            _itemsControl.ItemTemplate = GroupItemTemplate;
            _itemsControl.ItemsPanel = GroupItemsPanel;
            _itemsControl.ItemsSource = ItemsSource;

            _itemsControl.GroupSelected += itemsControl_GroupSelected;

            _groupSelectorPopup.Child = _border;
            ScrollViewer sv = new ScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled };

            _itemsControl.HorizontalAlignment = HorizontalAlignment.Center;
            _itemsControl.Margin = new Thickness(0, 12, 0, 0);
            _border.Child = sv;
            sv.Content = _itemsControl;

            SetItemsControlSize();
        }
        private void BuildPopup()
        {
            _groupSelectorPopup = new Popup();
            _groupSelectorPopup.Opened += popup_Opened;

            // Support the background color jumping through. Note that the 
            // alpha channel will be ignored, unless it is a purely transparent
            // value (such as when a user uses Transparent as the background
            // on the control).
            SolidColorBrush background = Background as SolidColorBrush;
            Color bg = (Color)Resources["PhoneBackgroundColor"];
            if (background != null 
                && background.Color != null 
                && background.Color.A > 0)
            {
                bg = background.Color;
            }
            _border = new Border
            {
                Background = new SolidColorBrush(
                    Color.FromArgb(0xa0, bg.R, bg.G, bg.B))
            };
            
            // Prevents touch events from bubbling up for most handlers.
            _border.ManipulationStarted += ((o, e) => e.Handled = true);
            _border.ManipulationCompleted += ((o, e) => e.Handled = true);
            _border.ManipulationDelta += ((o, e) => e.Handled = true);
            
            var gestureHandler = new EventHandler<System.Windows.Input.GestureEventArgs>((o, e) => e.Handled = true);
            _border.Tap += gestureHandler;
            _border.DoubleTap += gestureHandler;
            _border.Hold += gestureHandler;

            _itemsControl = new LongListSelectorItemsControl();
            _itemsControl.ItemTemplate = GroupItemTemplate;
            _itemsControl.ItemsPanel = GroupItemsPanel;
            _itemsControl.ItemsSource = ItemsSource;

            _itemsControl.GroupSelected += itemsControl_GroupSelected;

            _groupSelectorPopup.Child = _border;
            ScrollViewer sv = new ScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled };

            _itemsControl.HorizontalAlignment = HorizontalAlignment.Center;
            _itemsControl.Margin = new Thickness(0, 12, 0, 0);
            _border.Child = sv;
            sv.Content = _itemsControl;

            SetItemsControlSize();
        }