Iam Trying to Bind "Description" column value of dataGrid to command parameter of a button inside same grid row but, Binding not working properly. code:-
<DataGrid x:Name="devicelist" Background="SkyBlue" AutoGenerateColumns="False" ItemsSource="{Binding Path=DeviceList}" SelectionChanged="devicelist_SelectionChanged" >
<DataGrid.Columns>
<!--Description-->
<DataGridTextColumn Header="Descrition" Width="*" IsReadOnly="True" Binding="{Binding Path=Description}">
</DataGridTextColumn>
<!--testcaseSelection button-->
<DataGridTemplateColumn Header="TestCases" Width="*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType= {x:Type Window}},
Path=DataContext.CurrentViewModel.SelectTestCommand}" CommandParameter="{Binding Path=Description}" >TestCases</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
the command that i have binded is working properly and getting called also.
As explained here, try to declare the
CommandParameter
before theCommand
: