Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }