Пример #1
0
        private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            ButtonBase buttonBase = dependencyObject as ButtonBase;

            if (buttonBase != null)
            {
                ButtonBaseClickCommandBehavior behavior = GetOrCreateBehavior(buttonBase);
                behavior.CommandParameter = e.NewValue;
            }
        }
Пример #2
0
        private static ButtonBaseClickCommandBehavior GetOrCreateBehavior(ButtonBase buttonBase)
        {
            ButtonBaseClickCommandBehavior behavior = buttonBase.GetValue(ClickCommandBehaviorProperty) as ButtonBaseClickCommandBehavior;

            if (behavior == null)
            {
                behavior = new ButtonBaseClickCommandBehavior(buttonBase);
                buttonBase.SetValue(ClickCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }