Binding not working correctly in silverlight
- by Harsh Maurya
I am using a DataGrid in my silverlight project which contains a custom checkbox column. I have binded its command property with a property of my ViewModel class. Now, the problem is that I want to send the "selected item" of DataGrid through the command paramter for which I have written the following code :
<sdk:DataGrid AutoGenerateColumns="False" Margin="10,0,10,0" Name="dataGridOrders" ItemsSource="{Binding OrderList}" Height="190">
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn Header="Select">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox>
<is:Interaction.Triggers>
<is:EventTrigger EventName="Checked">
<is:InvokeCommandAction Command="{Binding Source={StaticResource ExecutionTraderHomePageVM},Path=OrderSelectedCommand,Mode=TwoWay}"
CommandParameter="{Binding ElementName=dataGridOrders,Path=SelectedItem}" />
</is:EventTrigger>
<is:EventTrigger EventName="Unchecked">
<is:InvokeCommandAction Command="{Binding Source={StaticResource ExecutionTraderHomePageVM},Path=OrderSelectedCommand,Mode=TwoWay}"
CommandParameter="{Binding ElementName=dataGridOrders,Path=SelectedItem}" />
</is:EventTrigger>
</is:Interaction.Triggers>
</CheckBox>
But I am always getting null in the parameter of my command's execute method. I have tried with other properties of DataGrid such as Width, ActualHeight e.t.c. but of no use. What am I missing here ?