TextChanged() static private method

static private TextChanged ( object sender, System.Windows.Controls.TextChangedEventArgs e ) : void
sender object
e System.Windows.Controls.TextChangedEventArgs
return void
Beispiel #1
0
        private static void OnIsMonitoringChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is TextBox)
            {
                TextBox textBox = d as TextBox;
                if (!(bool)e.NewValue)
                {
                    textBox.TextChanged -= new TextChangedEventHandler(TextBoxHelper.TextChanged);
                    textBox.GotFocus    -= new RoutedEventHandler(TextBoxHelper.TextBoxGotFocus);
                    return;
                }
                textBox.TextChanged += new TextChangedEventHandler(TextBoxHelper.TextChanged);
                textBox.GotFocus    += new RoutedEventHandler(TextBoxHelper.TextBoxGotFocus);
                textBox.Dispatcher.BeginInvoke(new Action(() => TextBoxHelper.TextChanged(textBox, new TextChangedEventArgs(TextBoxBase.TextChangedEvent, UndoAction.None))), new object[0]);
                return;
            }
            if (!(d is PasswordBox))
            {
                if (d is NumericUpDown)
                {
                    NumericUpDown newValue = d as NumericUpDown;
                    newValue.SelectAllOnFocus = (bool)e.NewValue;
                    if ((bool)e.NewValue)
                    {
                        newValue.ValueChanged += new RoutedPropertyChangedEventHandler <double?>(TextBoxHelper.OnNumericUpDownValueChaged);
                        newValue.GotFocus     += new RoutedEventHandler(TextBoxHelper.NumericUpDownGotFocus);
                        return;
                    }
                    newValue.ValueChanged -= new RoutedPropertyChangedEventHandler <double?>(TextBoxHelper.OnNumericUpDownValueChaged);
                    newValue.GotFocus     -= new RoutedEventHandler(TextBoxHelper.NumericUpDownGotFocus);
                }
                return;
            }
            PasswordBox passwordBox = d as PasswordBox;

            if (!(bool)e.NewValue)
            {
                passwordBox.PasswordChanged -= new RoutedEventHandler(TextBoxHelper.PasswordChanged);
                passwordBox.GotFocus        -= new RoutedEventHandler(TextBoxHelper.PasswordGotFocus);
                return;
            }
            passwordBox.PasswordChanged += new RoutedEventHandler(TextBoxHelper.PasswordChanged);
            passwordBox.GotFocus        += new RoutedEventHandler(TextBoxHelper.PasswordGotFocus);
            passwordBox.Dispatcher.BeginInvoke(new Action(() => TextBoxHelper.PasswordChanged(passwordBox, new RoutedEventArgs(PasswordBox.PasswordChangedEvent, passwordBox))), new object[0]);
        }
Beispiel #2
0
        private static void ButtonCommandOrClearTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TextBox textBox = d as TextBox;

            if (textBox != null)
            {
                textBox.Loaded -= new RoutedEventHandler(TextBoxHelper.TextChanged);
                textBox.Loaded += new RoutedEventHandler(TextBoxHelper.TextChanged);
                if (textBox.IsLoaded)
                {
                    TextBoxHelper.TextChanged(textBox, new RoutedEventArgs());
                }
            }
            PasswordBox passwordBox = d as PasswordBox;

            if (passwordBox != null)
            {
                passwordBox.Loaded -= new RoutedEventHandler(TextBoxHelper.PasswordChanged);
                passwordBox.Loaded += new RoutedEventHandler(TextBoxHelper.PasswordChanged);
                if (passwordBox.IsLoaded)
                {
                    TextBoxHelper.PasswordChanged(passwordBox, new RoutedEventArgs());
                }
            }
            ComboBox comboBox = d as ComboBox;

            if (comboBox != null)
            {
                comboBox.Loaded -= new RoutedEventHandler(TextBoxHelper.ComboBoxLoaded);
                comboBox.Loaded += new RoutedEventHandler(TextBoxHelper.ComboBoxLoaded);
                if (comboBox.IsLoaded)
                {
                    TextBoxHelper.ComboBoxLoaded(comboBox, new RoutedEventArgs());
                }
            }
        }