private void Button_Click(object sender, RoutedEventArgs e) { DbOperations db = new DbOperations(); try { List <Person> persons = db.GetAllPersons(); listBox1.ItemsSource = persons; } catch (PostgresException ex) { MessageBox.Show(ex.Message); } }