コード例 #1
0
        /// <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.
            BlotterComboBox comboBox = sender as BlotterComboBox;

            if (comboBox.NullSafe(p => p.SelectedValue) != null)
            {
                this.SetValue(ComboBox.SelectedValueProperty, comboBox.SelectedValue);
            }
        }
コード例 #2
0
        /// <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.
            BlotterComboBox viewerPrototype = dependencyObject as BlotterComboBox;
            Object          obj             = dependencyPropertyChangedEventArgs.NewValue;

            // The selected value of the base class is set here.
            try
            {
                InputHelper.IsPropertyUpdate = true;
                viewerPrototype.SetValue(ComboBox.SelectedValueProperty, obj);
            }
            finally
            {
                InputHelper.IsPropertyUpdate = false;
            }
        }