Pass whole row as parameter of DataGridTemplateColumn Hyperlink

岁酱吖の 提交于 2019-12-02 04:43:17

问题


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:


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>


来源:https://stackoverflow.com/questions/11287305/pass-whole-row-as-parameter-of-datagridtemplatecolumn-hyperlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!