Exemple #1
0
        private void AddButtonClicked()
        {
            try
            {
                var parent = VisualTreeExtensions.FindParent <MainCalendarView>(this);
                if (parent == null)
                {
                    throw new NullReferenceException("Couldn't find parent.");
                }

                CalendarViewModel viewModel = parent.ViewModel;
                if (viewModel == null)
                {
                    throw new NullReferenceException("Parent's view model was null");
                }

                App.ShowFlyoutAddHomeworkOrExam(
                    elToCenterFrom: _addButton,
                    addHomeworkAction: delegate { viewModel.AddHomework(base.Date); },
                    addExamAction: delegate { viewModel.AddExam(base.Date); },
                    addHolidayAction: delegate { viewModel.AddHoliday(base.Date); });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
        private void showPopupMenuAdd()
        {
            try
            {
                App.ShowFlyoutAddHomeworkOrExam(
                    elToCenterFrom: buttonAdd,
                    addHomeworkAction: delegate { _viewModel.AddHomework(false); },
                    addExamAction: delegate { _viewModel.AddExam(false); },
                    addHolidayAction: delegate { _viewModel.AddHoliday(false); });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }