Ejemplo n.º 1
0
        private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            TreeView tv = dependencyObject as TreeView;

            if (tv != null)
            {
                TreeViewSelectionChangedCommandBehavior behavior = GetOrCreateBehavior(tv);
                behavior.CommandParameter = e.NewValue;
            }
        }
Ejemplo n.º 2
0
        private static TreeViewSelectionChangedCommandBehavior GetOrCreateBehavior(TreeView treeView)
        {
            TreeViewSelectionChangedCommandBehavior behavior =
                treeView.GetValue(SelectCommandBehaviorProperty) as TreeViewSelectionChangedCommandBehavior;

            if (behavior == null)
            {
                behavior = new TreeViewSelectionChangedCommandBehavior(treeView);
                treeView.SetValue(SelectCommandBehaviorProperty, behavior);
            }
            return(behavior);
        }