Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Hyperlink in Grid
posted

I'm trying to leverage a hyperlink my xamDataGrid so that clicking on the text fires an event to my viewmodel with unique ID associated with my row.

<Style x:Key="HyperlinkStyle" TargetType="{x:Type igDP:CellValuePresenter}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

<TextBlock Margin="{TemplateBinding Padding}" VerticalAlignment="Center" TextAlignment="Left"><Hyperlink Click="Navigate" Tag="{Binding}" >

<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path =Value}"/>

</Hyperlink>

</TextBlock>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

I can figure out which row's hyperlink has been clicked by converting the hyperlink's tag to a datarecord, then converting the dataitem of that datarecord into my object and checking it's id property.  I'm wondering if there isn't a more elegent way to go about this?

Parents Reply Children
No Data