private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { Selector element = dependencyObject as Selector; if (element != null) { SelectionChangedBehavior behavior = GetOrCreateBehavior(element); behavior.Command = e.NewValue as ICommand; } }
private static SelectionChangedBehavior GetOrCreateBehavior(Selector element) { SelectionChangedBehavior behavior = element.GetValue(SelectionChangedBehaviourProperty) as SelectionChangedBehavior; if (behavior == null) { behavior = new SelectionChangedBehavior(element); element.SetValue(SelectionChangedBehaviourProperty, behavior); } return(behavior); }
public static void SetSelectionChangedBehavior(DependencyObject obj, SelectionChangedBehavior value) { obj.SetValue(SelectionChangedBehaviourProperty, value); }