/// <summary> /// Handles a change to the selected value. /// </summary> /// <param name="sender">The object that owns the property.</param> /// <param name="e">Describes the changed selection.</param> private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { // The 'SelectedValue' property of the base class was covered up with a new property that had the ability to remember // the selected value and use it to select an item after the special list was initialized. This propogates the // selected item up into the overriden property when the item is modified by the user. DebtRuleComboBox comboBox = sender as DebtRuleComboBox; if (comboBox.NullSafe(p => p.SelectedValue) != null) { this.SetValue(ComboBox.SelectedValueProperty, comboBox.SelectedValue); } }
/// <summary> /// Handles a change to the SelectedValue property. /// </summary> /// <param name="dependencyObject">The object that owns the property.</param> /// <param name="dependencyPropertyChangedEventArgs">A description of the changed property.</param> private static void OnSelectedValueChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // Extract the strongly typed variables from the generic parameters. DebtRuleComboBox comboBox = dependencyObject as DebtRuleComboBox; object obj = dependencyPropertyChangedEventArgs.NewValue; // The selected value of the base class is set here. try { InputHelper.IsPropertyUpdate = true; comboBox.SetValue(ComboBox.SelectedValueProperty, obj); } finally { InputHelper.IsPropertyUpdate = false; } }
/// <summary> /// /// </summary> /// <param name="dependencyObject"></param> /// <param name="dependencyPropertyChangedEventArgs"></param> private static void OnBlotterIdChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { // Extract the strongly typed variables from the generic parameters. DebtRuleComboBox comboBox = dependencyObject as DebtRuleComboBox; Guid blotterId = (Guid)dependencyPropertyChangedEventArgs.NewValue; if (comboBox.debtRuleList != null) { comboBox.debtRuleList.Initialized -= comboBox.OnDebtRuleListInitialized; comboBox.debtRuleList.Dispose(); } comboBox.debtRuleList = new DebtRuleList(blotterId); comboBox.debtRuleList.Initialized += comboBox.OnDebtRuleListInitialized; comboBox.SetBinding(ComboBox.ItemsSourceProperty, new Binding() { Source = comboBox.debtRuleList }); }