コード例 #1
0
        Cell FindCell(GestureEventArgs e, out FrameworkElement element)
        {
            Cell cell = null;

            element = e.OriginalSource as FrameworkElement;
            if (element != null)
            {
                cell = element.DataContext as Cell;
            }

            if (cell == null)
            {
                System.Windows.Point    pos      = e.GetPosition(_listBox);
                IEnumerable <UIElement> elements = VisualTreeHelperEx.FindElementsInHostCoordinates(pos, _listBox);
                foreach (FrameworkElement frameworkElement in elements.OfType <FrameworkElement>())
                {
                    if ((cell = frameworkElement.DataContext as Cell) != null)
                    {
                        element = frameworkElement;
                        break;
                    }
                }
            }

            return(cell);
        }
コード例 #2
0
        bool FindIndices(GestureEventArgs e, out int sectionIndex, out int cellIndex)
        {
            sectionIndex = 0;
            cellIndex    = 0;

            TableSection section = null;
            Cell         cell    = null;

            System.Windows.Point pos = e.GetPosition(System.Windows.Application.Current.MainWindow);
            if (Device.Info.CurrentOrientation.IsLandscape())
            {
                double x = pos.Y;
                double y = System.Windows.Application.Current.MainWindow.RenderSize.Width - pos.X + (SystemTray.IsVisible ? 72 : 0);
                pos = new System.Windows.Point(x, y);
            }
            IEnumerable <UIElement> elements = VisualTreeHelperEx.FindElementsInHostCoordinates(pos, System.Windows.Application.Current.MainWindow);

            foreach (FrameworkElement element in elements.OfType <FrameworkElement>())
            {
                if (cell == null)
                {
                    cell = element.DataContext as Cell;
                }
                else if (section == null)
                {
                    section = element.DataContext as TableSection;
                }
                else
                {
                    break;
                }
            }

            if (cell == null || section == null)
            {
                return(false);
            }

            sectionIndex = Element.Root.IndexOf(section);
            cellIndex    = section.IndexOf(cell);
            return(true);
        }