Pass whole row as parameter of DataGridTemplateCol

2019-02-26 21:35发布

Is it possible to pass a whole row as a parameter for the Hyperlink of DataGridTemplateColumn?

<my:DataGridTemplateColumn Header="Name">
  <my:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <TextBlock>
        <Hyperlink Foreground="Black" TextDecorations="None">
          <Run Text="{Binding Name}" />
        </Hyperlink>
      </TextBlock>
    </DataTemplate>
  </my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>

1条回答
Rolldiameter
2楼-- · 2019-02-26 22:04

Hard to tell what you are trying to achieve but a ComandParameter binding without a value should give you the row eg

<Hyperlink Foreground="Black" TextDecorations="None" CommandParameter="{Binding}" Command="{Binding methodThatHandlesTheHyperlinkClick}"> 
      <Run Text="{Binding Name}" /> 
</Hyperlink>
查看更多
登录 后发表回答