Not able to send CommandParameter

2 posts, 0 answers
  1. Shweta
    Shweta avatar
    11 posts
    Member since:
    Oct 2011

    Posted 04 Nov 2011 Link to this post

    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}" >
                                                        <Button Padding="7">
                                                                <interactivity:EventTrigger EventName="Click">
                                                                    <UI:CommandAction 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" />                                                           
                                                </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
  2. Daní
    Daní avatar
    314 posts
    Member since:
    Feb 2008

    Posted 04 Nov 2011 Link to this post


    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" />                                                        
Back to Top