通过全行作为DataGridTemplateColumn超链接的参数(Pass whole row

2019-07-30 04:55发布

是否有可能通过一整排为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>

Answer 1:

很难说你想什么来实现,但一个ComandParameter没有值绑定应该给你行如

<Hyperlink Foreground="Black" TextDecorations="None" CommandParameter="{Binding}" Command="{Binding methodThatHandlesTheHyperlinkClick}"> 
      <Run Text="{Binding Name}" /> 
</Hyperlink>


文章来源: Pass whole row as parameter of DataGridTemplateColumn Hyperlink