Пример #1
0
        private void SetGesture(LessonGridView gridItem, int n)
        {
            var tgf = new TapGestureRecognizer();

            tgf.Tapped += (s, e) => OnLabelClicked(n);
            gridItem.GestureRecognizers.Add(tgf);
        }
Пример #2
0
        public LessonPage(int lessonN)
        {
            NavigationPage.SetBackButtonTitle(this, "");
            InitializeComponent();
            lessonNumber = lessonN;
            this.Title   = titleList[lessonNumber];
            int numViews = numLessons[lessonNumber];

            switch (lessonNumber)
            {
            case 0:
                lessonTitles    = lesson1Titles;
                lessonNav       = lesson1Nav;
                lessonQuestions = lesson1Questions;
                break;

            case 1:
                lessonTitles    = lesson2Titles;
                lessonNav       = lesson2Nav;
                lessonQuestions = lesson2Questions;
                break;

            case 2:
                lessonTitles    = lesson3Titles;
                lessonNav       = lesson3Nav;
                lessonQuestions = lesson3Questions;
                break;

            default:
                break;
            }

            var grid = new Grid
            {
                RowSpacing    = 10,
                ColumnSpacing = 10
            };

            int row = 0;
            int col = 0;

            for (int i = 1; i <= numViews; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition
                {
                    Height = 185
                });
                LessonGridView v = new LessonGridView {
                    Title = lessonTitles[i - 1], Questions = lessonQuestions[i - 1] + " question(s)", Nav = lessonNav[i - 1]
                };
                grid.Children.Add(v, col, row);
                SetGesture(v, i);

                if (col == 0)
                {
                    col += 1;
                }
                else if (col == 1)
                {
                    row += 1;
                    col  = 0;
                }
            }



            //SetGesture(grid1, 1);
            //SetGesture(grid2, 2);
            //SetGesture(grid3, 3);
            //SetGesture(grid4, 4);
            //SetGesture(grid5, 5);
            //SetGesture(grid6, 6);
            //SetGesture(grid7, 7);
            //SetGesture(grid8, 8);
            //SetGesture(grid9, 9);
            stackLayout.Children.Add(grid);
        }