private void OnComboBoxSelectedIndexChanged(NValueChangeEventArgs args) { if (m_bSelectionUpdating) { m_bSelectionUpdating = false; return; } // Get the list box and the other list box int selectedIndex = (int)args.NewValue; NComboBox comboBox = (NComboBox)args.TargetNode; NComboBox otherComboBox = comboBox == m_ComboBox ? m_AdvancedComboBox : m_ComboBox; // Log the selection NComboBoxItem selectedItem = comboBox.SelectedItem; NCountry country = NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> .GetDataBoundItem(selectedItem); m_EventsLog.LogEvent("'" + country.Name + "' selected"); // Synchronize the selection between the two list boxes m_bSelectionUpdating = true; otherComboBox.SelectedIndex = selectedIndex; }
private void OnListBoxItemSelected(NSelectEventArgs <NListBoxItem> args) { if (m_bSelectionUpdating) { m_bSelectionUpdating = false; return; } // Get the list box and the other list box NListBox listBox = (NListBox)args.Item.OwnerListBox; NListBox otherListBox = listBox == m_ListBox ? m_AdvancedListBox : m_ListBox; // Log the selection NListBoxItem selectedItem = listBox.Selection.FirstSelected; NCountry country = NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> .GetDataBoundItem(selectedItem); m_EventsLog.LogEvent("'" + country.Name + "' selected"); // Synchronize the selection between the two list boxes m_bSelectionUpdating = true; int selectedIndex = listBox.Items.IndexOf(selectedItem); otherListBox.Selection.SingleSelect(otherListBox.Items[selectedIndex]); }