private void RadioButton_Checked(object sender, RoutedEventArgs e) { RadioButton button = sender as RadioButton; string title = (string)button.Content; Route r = API.ds.Routes.Where(d => d.Title == title).First(); currentRoute = r; currentIndex = buttons.IndexOf(button); if (r.Directions.Count > 1) { directionPanel.Children.Clear(); foreach (Direction d in r.Directions) { RadioButton newButton = new RadioButton(); newButton.Checked+=directionButton_Checked; newButton.Content = d.Title; newButton.GroupName = "Direction"; newButton.Style = Application.Current.Resources["TabRadioButtonStyle"] as Style; newButton.Margin = new Thickness(0, 0, 30, 0); //newButton.IsChecked = true; directionPanel.Children.Add(newButton); } (directionPanel.Children.First() as RadioButton).IsChecked = true; } else { directionPanel.Children.Clear(); currentDirection = r.Directions.First(); stopsList.ItemsSource = r.Stops; } //if ((string)button.Content == "Red") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Red").First().Stops; //if ((string)button.Content == "Blue") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Blue").First().Stops; //if ((string)button.Content == "Green") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Green").First().Stops; //if ((string)button.Content == "Trolley") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Tech Trolley").First().Stops; //if ((string)button.Content == "Night") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Night").First().Stops; //if ((string)button.Content == "Emory") // stopsList.ItemsSource = API.ds.Routes.Where(d => d.Title == "Emory Shuttle").First().Stops; }
private void directionButton_Checked(object sender, RoutedEventArgs e) { var directions = currentRoute.Directions; string title = (sender as RadioButton).Content as string; Direction d = directions.Where(f => f.Title == title).First(); stopsList.ItemsSource = d.Stops; currentDirection = d; }