TreeView and DelegateCommand

Topics: Prism v2 - WPF 3.5
Aug 14, 2009 at 7:08 PM

I'm trying to bind a DelegateCommand for a TreeView Expanded event.  I understand that this isn't supported by default and that I will need to implement CommandBehaviorBase<T>.  I tried to follow the ButtonBaseClickCommandBehavior example, but couldn't figure it out.  I think I'm getting confused because for a tree, you do something like:

<TreeView TreeViewItem.Expanded="TreeView_Expanded" />

And for a button you do something like:

<Button Click="Button_Click" />

Does having the Expanded event being under another element in the TreeView declaration make implementing the CommandBehaviorBase<T> significantly different than the ButtonBaseClickCommandBehavior?  For my TreeView, it is binding to an ItemsSource and then using a HierarchicalDataTemplate for each level in the tree.

Also, if this is possible, how can I pass the bound object in the expanded TreeViewItem with the Command?

Also, should I even be trying to use a DelegateCommand, or is there a better way to send events to the presenter?