Binding not working correctly in silverlight
Posted
by
Harsh Maurya
on Stack Overflow
See other posts from Stack Overflow
or by Harsh Maurya
Published on 2012-10-28T10:44:10Z
Indexed on
2012/10/28
11:00 UTC
Read the original article
Hit count: 263
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 ?
© Stack Overflow or respective owner