I am trying to use an attached behavior to execute a command in my ViewModel when the user Double Clicks on the list item.
I have reviewed a number of articles on the su
The problem is that the DataContext
for the Binding
is the string. Since there is no Foo
property of the string class, you are getting an error. This doesn't happen in the other cases because they inherit their DataContext
from the parent (this doesn't happen for automatically generated containers for data items - their DataContext
is the data item).
If you change your binding to use the parent ListView
's DataContext
, it should work fine:
Value="{Binding DataContext.Foo, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"