GetGestureListener() public static method

Gets a GestureListener for the new element. Will create a new one if necessary.
public static GetGestureListener ( DependencyObject obj ) : GestureListener
obj System.Windows.DependencyObject The object to get the GestureListener from.
return GestureListener
Exemplo n.º 1
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();
        }
            protected override void ClearContainerForItemOverride(DependencyObject element, object item)
            {
                base.ClearContainerForItemOverride(element, item);

                GestureService.GetGestureListener(element).Tap -= LongListSelectorItemsControl_Tap;
            }