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

Get row content by using RelativeSource

2 Answers 304 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Qin
Top achievements
Rank 1
Qin asked on 20 May 2013, 11:57 AM
Hello All,

I have RadGridView  which hava a button embeded.  The button is binded with a command and the command parameter is the content of each row.  The bind expression of CommandParameter is "{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}".   The problem is the command cannot get its parameter.  I am sure the command binding is works, because it is working well if I using a DataGrid insteast.   Does anyone could help me.

Thank you && Best Regards
Wei
 

 

<telerik:RadGridView x:Name="TradesGridView" 
 
ItemsSource="{Binding Trades, Mode=TwoWay}"
 CanUserFreezeColumns="False">
<telerik:RadGridView.Columns >
<telerik:GridViewColumn Header="Amend" >
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<controls:RadButton Grid.Column="4" IsBackgroundVisible="False" Margin="10 2" MinWidth="30" ToolTipService.ToolTip="Amend Trade"
  
 Command="{Binding Path=DataContext.AmendCommand, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DockPanel}}}"
  
CommandParameter="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}">
 
<Path Data="M3.6943,11.9199L4.1323,9.5549C4.1443,9.4019,4.1953,9.2459,4.2973,9.1289L9.4233,4.0049L11.8853,6.4669L6.7593,11.5919C6.7043,11.6469,6.4893,11.7749,6.4183,11.7869L4.0083,12.2339C3.7943,12.2749,3.6533,12.1349,3.6943,11.9199 M4.8903,11.4789L6.2383,11.2519L10.9273,6.5619L10.3673,6.0059L5.7093,10.6679L4.8153,9.7169L4.5693,11.1329C4.7253,11.1989,4.8253,11.3219,4.8903,11.4789 M12.4513,5.9019L9.9893,3.4399L10.7863,2.6439C11.0063,2.4229,11.3643,2.4229,11.5853,2.6439L13.2483,4.3069C13.4683,4.5269,13.4683,4.8849,13.2483,5.1059z"
Fill="#FF333333" Stretch="Fill" Width="12" Height="12" />
</controls:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>


2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 May 2013, 12:19 PM
Hi Wei,

 
Would you please try setting the CommandParameter like so:

<telerik:GridViewColumn Width="90">
    <telerik:GridViewColumn.CellTemplate>
        <DataTemplate>
            <telerik:RadButton ...
                               CommandParameter="{Binding}" />
        </DataTemplate>
    </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

I hope this helps.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Qin
Top achievements
Rank 1
answered on 22 May 2013, 01:36 AM
It works. Thank you :)
Tags
GridView
Asked by
Qin
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Qin
Top achievements
Rank 1
Share this question
or