Ejemplo n.º 1
0
        private static void OnSetCommandParameterCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ListView lv = d as ListView;

            if (lv != null)
            {
                //Acquire behavior attached to the list view and set the command parameter
                //The behavior class executes the command
                ListViewSelectCommandBehavior behavior =
                    GetOrCreateBehavior(lv);
                behavior.CommandParameter = e.NewValue;
            }
        }
Ejemplo n.º 2
0
        private static ListViewSelectCommandBehavior GetOrCreateBehavior(ListView lv)
        {
            //First get the behavior, maybe it is already created
            ListViewSelectCommandBehavior behavior =
                lv.GetValue(SelectCommandBehaviorProperty) as ListViewSelectCommandBehavior;

            if (behavior == null)
            {
                //if the behavior is not created then create one
                behavior = new ListViewSelectCommandBehavior(lv);
                lv.SetValue(SelectCommandBehaviorProperty, behavior);
            }
            //return the behavior
            //Caller function sets the command or command parameter properties
            return(behavior);
        }