private void keysToSelect_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (keysToSelect.SelectedIndex >= 0) { listBoxPairs.Add(new BoxKeyboardPair(KeyToString.convert((System.Windows.Forms.Keys)keysToSelect.SelectedValue), (System.Windows.Forms.Keys)keysToSelect.SelectedValue)); } }
public MacroAddControl() { InitializeComponent(); System.Windows.Forms.Keys[] keys = Enum.GetValues(typeof(System.Windows.Forms.Keys)).Cast <System.Windows.Forms.Keys>().ToArray(); foreach (System.Windows.Forms.Keys key in keys) { comboBoxPairs.Add(new BoxKeyboardPair(KeyToString.convert(key), key)); } keysToSelect.DisplayMemberPath = "_Key"; keysToSelect.SelectedValuePath = "_Value"; keysToSelect.ItemsSource = comboBoxPairs; currentKeysToBeAdded.DisplayMemberPath = "_Key"; currentKeysToBeAdded.SelectedValuePath = "_Value"; currentKeysToBeAdded.ItemsSource = listBoxPairs; }