First i would like to warn you that im all very new to the Prism framwork and in general in WPF any claims of me should therefore be validated.
And please, if im wrong tell me!
As far as I understand, Prism are only coming out of the box with a few Delegate Commands you can use directly in your ViewModels for a very few standard WPF controls, e.g. the Button control.
Please have a look on this EXTREMLY valuable video
My question is, wouldnt it be possible to do a sort of contrib library containing DelegateCommands that maps to the normal events we find in the WPF controls so we
can use them directly in our ViewModels / Controllers (like shown in the video link above)?
Which would be implemented as (this class must be able to be shared among us or what?) :
public static class TreeViewItemSelectedChanged
public static readonly DependencyProperty CommandProperty =
DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(TreeViewSelectedItemChanged),
public static readonly DependencyProperty MouseOverCommandBehaviorProperty =
typeof(TreeViewSelectedItemChangedBehaviour), typeof(TreeViewSelectedItemChanged), null);
public static ICommand GetCommand(DependencyObject obj)
return (ICommand) obj.GetValue(CommandProperty);
public static void SetCommand(DependencyObject obj, ICommand value)
private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
var element = dependencyObject as Control;
if (element != null)
TreeViewSelectedItemChangedBehaviour behavior = GetOrCreateBehavior(element);
behavior.Command = e.NewValue as ICommand;
private static TreeViewSelectedItemChangedBehaviour GetOrCreateBehavior(Control element)
var behavior = element.GetValue(MouseOverCommandBehaviorProperty) as TreeViewSelectedItemChangedBehaviour;
if (behavior == null)
behavior = new TreeViewSelectedItemChangedBehaviour(element);
public static TreeViewSelectedItemChangedBehaviour GetMouseOverCommandBehavior(DependencyObject obj)
public static void SetMouseOverCommandBehavior(DependencyObject obj, TreeViewSelectedItemChangedBehaviour value)
Have i missed something here or would this be possible? If this would be possible i think at least it would make the Prims framework even more valuable, to increase the time to get things solved.
Again, correct me if im wrong, im on thin ice here!!!
You might want to take a look at Marlon Grech's
attached command behaviors.