private void lvAnimals_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (object selectedItem in lvAnimals.SelectedItems) { Animal selectedAnimal = lvAnimals.SelectedItem as Animal; if (selectedAnimal != null) { Dog dog = selectedAnimal as Dog; if (dog != null) { dog.Bark(); } selectedAnimal.Speak(); } } }
private void Bark_Button_Click(object sender, RoutedEventArgs e) { Dog dog = new Dog(); dog.Bark(); }