private async void ExcelBtn_Click(object sender, RoutedEventArgs e) { MainBusy.IsBusy = true; var notemodel = new NoteViewModel(); string period = string.Empty; var mainModel = DataContext as MainViewModel; if (MonthStatRadio.IsChecked == true) //Month { if (MonthStatCombo.SelectedIndex == -1) { return; } int month = MonthStatCombo.SelectedIndex + 1; notemodel.SelectByMonth(month); mainModel.ExcelFileName = MonthStatCombo.SelectedItem.ToString(); } if (YearStatRadio.IsChecked == true) //Year { int year = (int)(YearStatUpDown.Value ?? DateTime.Now.Year); notemodel.SelectByYear(year); mainModel.ExcelFileName = year.ToString(); } await mainModel.ExcelStatCommand.ExecuteAsync(notemodel.Notes); MainBusy.IsBusy = false; }