private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { XamDataTree menuItem = dependencyObject as XamDataTree; if (menuItem != null) { XamDataTreeNodeActivatedCommandBehavior behavior = GetOrCreateBehavior(menuItem); behavior.CommandParameter = e.NewValue; } }
private static XamDataTreeNodeActivatedCommandBehavior GetOrCreateBehavior(XamDataTree menuItem) { XamDataTreeNodeActivatedCommandBehavior behavior = menuItem.GetValue(SelectedCommandBehaviorProperty) as XamDataTreeNodeActivatedCommandBehavior; if (behavior == null) { behavior = new XamDataTreeNodeActivatedCommandBehavior(menuItem); menuItem.SetValue(SelectedCommandBehaviorProperty, behavior); } return(behavior); }