AttachedCommandBehavior.CommandBehavior.SetBehavior C# (CSharp) Method

SetBehavior() private static method

Sets the Behavior property.
private static SetBehavior ( DependencyObject d, CommandBehaviorBinding value ) : void
d System.Windows.DependencyObject
value CommandBehaviorBinding
return void
        private static void SetBehavior(DependencyObject d, CommandBehaviorBinding value)
        {
            d.SetValue(BehaviorProperty, value);
        }

Usage Example

Beispiel #1
0
        //tries to get a CommandBehaviorBinding from the element. Creates a new instance if there is not one attached
        private static CommandBehaviorBinding FetchOrCreateBinding(DependencyObject d)
        {
            CommandBehaviorBinding binding = CommandBehavior.GetBehavior(d);

            if (binding == null)
            {
                binding = new CommandBehaviorBinding();
                CommandBehavior.SetBehavior(d, binding);
            }
            return(binding);
        }