I am using the MVVM Light toolkit and when I click on a button in a row's unbound column, I want to execute a command on the View's corresponding ViewModel passing the POCO in the row's DataContext as the command parameter.
This is what I have so far:
<igGrid:XamWebGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=ItemEntities}" > <igGrid:XamWebGrid.Columns> <!--Edit Column --> <igGrid:UnboundColumn Key="EditColumn"> <igGrid:UnboundColumn.ItemTemplate> <DataTemplate> <Button Content="Edit"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cmd:EventToCommand Command="{Binding Mode=OneWay, Path=EditItemCommand}" CommandParameter="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> </DataTemplate> </igGrid:UnboundColumn.ItemTemplate> </igGrid:UnboundColumn>
<igGrid:TextColumn Key="ItemId" HeaderText="ID" Width="55"/> <igGrid:TextColumn Key="Title" HeaderText="Title" Width="310"/> </igGrid:XamWebGrid.Columns>
</igGrid:XamWebGrid>
Hi,
I resolve this issue by creating an empty property in my "ViewModel" and adding a templatecolumn and adjusting behavior as a UnboundColumn:
<ig:TemplateColumn Key="Adicionar" IsFilterable="False" IsSortable="False" Width="Auto" HorizontalContentAlignment="Center"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <Button Content="+" Command="{Binding Path=AdicionarCommand}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> </ig:TemplateColumn >
It is SL 4.0
Jaimir G.