AttachedCommandBehavior.CommandBehavior.GetBehavior C# (CSharp) Method

GetBehavior() private static method

Gets the Behavior property.
private static GetBehavior ( DependencyObject d ) : CommandBehaviorBinding
d System.Windows.DependencyObject
return CommandBehaviorBinding
        private static CommandBehaviorBinding GetBehavior(DependencyObject d)
        {
            return (CommandBehaviorBinding) d.GetValue(BehaviorProperty);
        }

Usage Example

Example #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);
        }