コード例 #1
0
        private void buttonAddToTeam_Click(object sender, RoutedEventArgs e)
        {
            var found = false;

            foreach (RemovableListItem item in stackPanelMembers.Children)
            {
                if ((string)item.Tag == (string)((ComboBoxItem)comboBoxAddToTeam.SelectedItem).Tag)
                {
                    found = true;
                    break;
                }
            }

            if ((string)((ComboBoxItem)comboBoxTeamLead.SelectedItem).Tag == (string)((ComboBoxItem)comboBoxAddToTeam.SelectedItem).Tag)
            {
                found = true;
            }

            if (!found)
            {
                var selectedItem = (ComboBoxItem)comboBoxAddToTeam.SelectedItem;
                var newItem      = new RemovableListItem((string)selectedItem.Content, selectedItem.Tag);
                newItem.RemoveMe += new EventHandler <RoutedEventArgs>(stackPanelMembers_RemoveMe);
                stackPanelMembers.Children.Add(newItem);
            }
        }
コード例 #2
0
 private void comboBoxTeamLead_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (stackPanelMembers != null)
     {
         RemovableListItem removeThis = null;
         foreach (RemovableListItem item in stackPanelMembers.Children)
         {
             if ((string)item.Tag == (string)((ComboBoxItem)comboBoxTeamLead.SelectedItem).Tag)
             {
                 removeThis = item;
                 break;
             }
         }
         stackPanelMembers.Children.Remove(removeThis);
     }
 }