Exemplo n.º 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.ShowFlyoutAddTaskOrEvent(
                    elToCenterFrom: _addButton,
                    addTaskAction: delegate { viewModel.AddTask(base.Date); },
                    addEventAction: delegate { viewModel.AddEvent(base.Date); },
                    addHolidayAction: delegate { viewModel.AddHoliday(base.Date); });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
        private void showPopupMenuAdd()
        {
            try
            {
                App.ShowFlyoutAddTaskOrEvent(
                    elToCenterFrom: buttonAdd,
                    addTaskAction: delegate { _viewModel.AddTask(false); },
                    addEventAction: delegate { _viewModel.AddEvent(false); },
                    addHolidayAction: delegate { _viewModel.AddHoliday(false); });
            }

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