Пример #1
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);
        }