Hi, I've managed to include a hyperlink with a click handler in a databound gridview cell like this... <GridViewColumn Header="Title"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock> <Hyperlink Click="Hyper_OnClick"> <TextBlock Text="{Binding Path=AttachmentTitle}" /> </Hyperlink> </TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> but can't figure out how to get the text for the link as a string inside the hyperlink click handler. How can I do this?
On Oct 10, 4:32 pm, Scott Walters wrote: > Hi, > > I've managed to include a hyperlink with a click handler in a databound > gridview cell like this... > > <GridViewColumn Header="Title"> > <GridViewColumn.CellTemplate> > <DataTemplate> > <TextBlock> > <Hyperlink Click="Hyper_OnClick"> > <TextBlock Text="{Binding Path=AttachmentTitle}" /> > </Hyperlink> > </TextBlock> > </DataTemplate> > </GridViewColumn.CellTemplate> > </GridViewColumn> > > but can't figure out how to get the text for the link as a string inside > the hyperlink click handler. How can I do this? I used your example -- works great by the way -- for a list of customers that I had. When I clicked on the customer I wanted to edit that record. Therefore, in the "Tag" of the Hyperlink I placed a binding to the customer id. That was the easiest way I found to recover information I needed about the record that was clicked. Here is the snippet... <ListView Name="customerList"> <ListView.View> <GridView> <GridViewColumn Header="Name"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock> <Hyperlink Click="EditCustomer" Tag="{Binding Path=customerid}"> <TextBlock Text="{Binding Path=name}"/> </Hyperlink> </TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> and here is an example for accessing it... MessageBox.Show("Customer: " + ((Hyperlink)sender).Tag.ToString()); ... it works great!