private void ClassCountListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ClassCountListBox != null) { ListBoxItem item = ClassCountListBox.SelectedItem as ListBoxItem; _classCount = Convert.ToInt32(item.Content); ClassCountChoicesPage.IsOpen = false; } }