示例#1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     SelectedPersonTextBox.Clear();
     Year1.Clear();
     Year2.Clear();
     RBFirstName.IsChecked = false;
     RBLastName.IsChecked  = false;
     RBRating.IsChecked    = false;
     RBStartDate.IsChecked = false;
     dataGrid.ItemsSource  = null;
     dataGrid.ItemsSource  = Person.PersonList();
 }
示例#2
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (!int.TryParse(Year1.Text, out int result) || !int.TryParse(Year2.Text, out int result2))
            {
                MessageBox.Show("Enter two valid years");
                Year1.Clear();
                Year2.Clear();
                YearCheckBox.IsChecked = false;
            }

            else
            {
                IEnumerable <Person> newList = (List <Person>)dataGrid.ItemsSource;
                newList = newList.Where(x => x.startDate >= int.Parse(Year1.Text) && x.startDate <= int.Parse(Year2.Text)).ToList();
                dataGrid.ItemsSource         = null;
                dataGrid.ItemsSource         = newList;
                ((CheckBox)sender).IsChecked = false;
            }
        }