Exemplo n.º 1
0
        private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            var selector = dependencyObject as Selector;

            if (selector == null)
            {
                return;
            }
            SelectorSelectionChangedCommandBehavior behavior = GetOrCreateBehavior(selector);

            behavior.Command = e.NewValue as ICommand;
        }
Exemplo n.º 2
0
        private static SelectorSelectionChangedCommandBehavior GetOrCreateBehavior(Selector selector)
        {
            var behavior = selector.GetValue(SelectionChangedCommandBehaviorProperty) as SelectorSelectionChangedCommandBehavior;

            if (behavior == null)
            {
                behavior = new SelectorSelectionChangedCommandBehavior(selector);
                selector.SetValue(SelectionChangedCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }