Example #1
0
        static void OnCommandOnTextChangedChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
        {
            TextBox sender  = (TextBox)source;
            var     command = GetTextboxCommand(sender);

            if (command != null)
            {
                command.Detach();
                SetTextboxCommand(sender, null);
            }

            if (args.NewValue != null)
            {
                command = new TextboxCommand()
                {
                    TextBox = sender,
                    Command = (ICommand)args.NewValue
                };
                command.Attach();
                SetTextboxCommand(sender, command);
            }
        }
Example #2
0
 static void SetTextboxCommand(DependencyObject obj, TextboxCommand value)
 {
     obj.SetValue(TextboxCommandProperty, value);
 }