예제 #1
0
        private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            ListBox lb = dependencyObject as ListBox;

            if (lb != null)
            {
                ListBoxSelectionChangedCommandBehavior behavior = GetOrCreateBehavior(lb);
                behavior.CommandParameter = e.NewValue;
            }
        }
예제 #2
0
        private static ListBoxSelectionChangedCommandBehavior GetOrCreateBehavior(ListBox listBox)
        {
            ListBoxSelectionChangedCommandBehavior behavior =
                listBox.GetValue(SelectCommandBehaviorProperty) as ListBoxSelectionChangedCommandBehavior;

            if (behavior == null)
            {
                behavior = new ListBoxSelectionChangedCommandBehavior(listBox);
                listBox.SetValue(SelectCommandBehaviorProperty, behavior);
            }
            return(behavior);
        }