private void ContainerTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) { //load container names combo box KeyValuePair <long, string> s = (KeyValuePair <long, string>)((ComboBox)sender).SelectedValue; MainWindow wnd = Application.Current.MainWindow as MainWindow; List <ContainerNameDTO> containerNames = wnd.GetContainerNamesByType(s.Key); ObservableCollection <KeyValuePair <long, string> > list2 = new ObservableCollection <KeyValuePair <long, string> >(); foreach (ContainerNameDTO dto in containerNames) { list2.Add(new KeyValuePair <long, string>(dto.ContainerNameId, dto.ContainerName)); } this.ContainerNames.ItemsSource = null; this.ContainerNames.ItemsSource = list2; }