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