private void btn_selectApplication_unit_Click(object sender, RoutedEventArgs e) { string name = this.nametext.Text; string group = this.cbb_group.Text; int membermin = 0; int membermax = 0; if (this.members_10.IsChecked == true) { membermin = 1; membermax = 10; } if (this.members_20.IsChecked == true) { membermin = 11; membermax = 20; } if (this.members_30.IsChecked == true) { membermin = 21; membermax = 30; } if (this.members_40.IsChecked == true) { membermin = 31; membermax = 40; } if (this.members_40up.IsChecked == true) { membermin = 41; membermax = 0; } Application_unit_ViewModel application_Unit_ViewModel = new Application_unit_ViewModel(); List <Application_unit_ViewModel> Application_unit_ViewModels = application_Unit_ViewModel.SelectApplication_unit(name, group, membermin, membermax); ObservableCollection <application_Unit_list> application_Unit_lists = new ObservableCollection <application_Unit_list>(); foreach (var row in Application_unit_ViewModels) { application_Unit_lists.Add(new application_Unit_list() { 運用單位 = row.Application_unit, 組別 = row.Group, 運用單位聯絡電話 = row.Application_phone_no, 負責人 = row.Principal, 負責人聯絡電話 = row.Principal_phone_no, 志工總人數 = row.Total_volunteers }); } this.dg_Application_unit.ItemsSource = application_Unit_lists; }