I am using MV-VM and have a command in my ViewModel called EntitySelectedCommand.
I am trying to get all the items in an ItemsControl to run this command, however it does not work.
I think because each datacontext element is a separate object to which the element is bound, and not the ViewModel?
Can someone point me in the right direction?
Greetings
Andy
<ItemsControl ItemsSource="{Binding Path=LinkedSuppliers}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <Controls:EntityLabel Grid.Column="0" Grid.Row="0" Content="{Binding Name}" CurrentEntity="{Binding }" EntitySelected="{Binding EntitySelectedCommand}" ></Controls:EntityLabel> <StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
data-binding wpf mvvm itemscontrol
Andy clarke
source share