예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static void SetSelectionChangedBehavior(DependencyObject obj,
                                                SelectionChangedBehavior value)
 {
     obj.SetValue(SelectionChangedBehaviourProperty, value);
 }