The first thing you will have to do is create a template for the TreeViewItems that sets the AttachedBehavior for each
TreeViewItem created in the TreeView. Assuming you are using
Silverlight 3 (based on your history of asked/answered questions), there is no way of doing the binding to the command through XAML (as there is not RelativeSource property for binding other than Self) since the DataContext of the TreeViewItem
is the DataSource of the TreeView.
A possible workaround could be having a StaticResource in your XAML, and instead of binding directly to the Command in the
TreeViewTemplate, bind to the StaticResource. In the View's code behind, you can bind the Resource to the command in the ViewModel.
The Prism-v2 Silverlight RI, uses a similar approach (with an ObservableCommand) in the PositionSummaryView and ViewModel to bind to a command in a different data context. You might find
Please let me know if this helps.