private void Next_Click(object sender, RoutedEventArgs e) { List <int> places = new List <int>(); foreach (var item in busCanvas.Children) { if (item is CheckBox) { var c = item as CheckBox; if (c.IsChecked == true) { string str = c.Name; str = str.Replace("place", ""); places.Add(Int32.Parse(str)); } } } OrderWindow orderWindow = new OrderWindow(CurrentTrip, places); orderWindow.Show(); }