This is a migrated thread and some comments may be shown as answers.

Not able to send CommandParameter

1 Answer 91 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shweta
Top achievements
Rank 1
Shweta asked on 04 Nov 2011, 11:58 AM

My problem statement is to add a column in grid with button. And on click of that, I want to perform some action on that particular row. My grid name is GridIndex.

My code in View (xaml) is as below:    

<telerikGrid:GridViewDataColumn Header="{Binding Source={StaticResource c}, Path=s.Action}"  Width="Auto" DataMemberBinding="{Binding Action,Mode=TwoWay}" >
                                                <telerikGrid:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>                                                  
                                                    <Button Padding="7">
                                                        <interactivity:Interaction.Triggers>
                                                            <interactivity:EventTrigger EventName="Click">
                                                                <UI:CommandAction Command="{Binding Source={StaticResource ServiceLocator}, Path=EventLogViewModel.AcknowledgeCommand}" CommandParameter="{Binding ElementName=GridIndex}"/>
                                                            </interactivity:EventTrigger>
                                                        </interactivity:Interaction.Triggers>
                                                        <StackPanel Orientation="Horizontal">
                                                            <Image  Height="12" Source="/Cirrus.Core.UI.Images;component/Images/check.png" />                                                           
                                                        </StackPanel>
                                                    </Button>
                                                    </DataTemplate>
                                                </telerikGrid:GridViewDataColumn.CellTemplate>
                                            </telerikGrid:GridViewDataColumn >

My code in ViewModel is as below:    
AcknowledgeCommand = new DelegateCommand<object>(Acknowledge, CanAcknowledge);  
public void Acknowledge(object ackData)
{
 .............
 .............
}

Everytime, I am getting ackData as null. Kindly tell me, how can I get data into ackData

for further processing

1 Answer, 1 is accepted

Sort by
0
Daní
Top achievements
Rank 1
answered on 04 Nov 2011, 03:07 PM
Hi

I think it would be easier binding your command directly to the button command and not ussing the trigger. Code should look similar to:
<Button Padding="7" Command="{Binding Source={StaticResource ServiceLocator},  Path=EventLogViewModel.AcknowledgeCommand}"
CommandParameter="{Binding ElementName=GridIndex}">
  <StackPanel Orientation="Horizontal
<Image  Height="12" Source="/Cirrus.Core.UI.Images;component/Images/check.png" />                                                        
    </StackPanel>
</Button>
Tags
GridView
Asked by
Shweta
Top achievements
Rank 1
Answers by
Daní
Top achievements
Rank 1
Share this question
or