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

            if (menuItem != null)
            {
                TreeViewCommandBehavior behavior = GetOrCreateBehavior(menuItem);
                behavior.CommandParameter = e.NewValue;
            }
        }
예제 #2
0
        private static TreeViewCommandBehavior GetOrCreateBehavior(TreeView menuItem)
        {
            TreeViewCommandBehavior behavior = menuItem.GetValue(SelectedCommandBehaviorProperty) as TreeViewCommandBehavior;

            if (behavior == null)
            {
                behavior = new TreeViewCommandBehavior(menuItem);
                menuItem.SetValue(SelectedCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }