I have a data grid that lists information present in an observable collection. So far everything is working fine.
I would then like to add a stop command which Name property as a parameter but when i write CommandParameter= {Binding Name}, my button is disable. I try to set CommandParameter with a random string and that's working, so the probleme comes from the binding.
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{ Binding Name }"/>
<DataGridTextColumn Header="Source" Binding="{ Binding Source }"/>
<DataGridTextColumn Header="Target" Binding="{ Binding Target }"/>
<DataGridTemplateColumn Header="Stop">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Stop"
Command="{ Binding DataContext.StopCommand, RelativeSource = { RelativeSource FindAncestor,AncestorType={ x:Type DataGrid } } }"
CommandParameter="{ Binding Name }"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Thanks you !