Search code examples
wpfbindingcommanddatatemplate

Bind to collection commands in data template


I have a list box with a collection as its data context and I have defined a data template to have specific view of collection items.

I want to execute commands at the collection level that may apply to some items or not and want to use them in data template. There are a lot of code to insert, but hope that this picture give you the general idea.

enter image description here

How can I define such commands in data templates that binds to command at collection level and how to know which item has sent the command?


Solution

  • I finally found the solution in the following article :

    Command Binding inside DataTemplate in Parent-Child Scenario in an MVVM Application

    By Amit Kumar Dutta