Tag Archives: MVVM

Commanding within DataTemplates in MVVM!

A quick post about setting commands within DataTemplates when using the MVVM pattern! When you are inside a DataTemplate the DataContext is changed to the  the current item, so to access the command you will need to use the “relative source” Something like <Button Content=”Delete” Width=”Auto” Command=”{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}” CommandParameter=”{Binding}”> Hope this […]