Quantcast
Viewing all articles
Browse latest Browse all 18858

Hyperlink in a datagrid cell - No way to get the parent cell of the Hyperlink ?

Hi,

I have the following template for a WPF 4.0 Datagrid cell -

<DataTemplate x:Key="ReadOnlyHyperlinkTemplate"><Border Padding="3"><TextBlock Name="txt"><Hyperlink Focusable=true Click="OnReadOnlyHyperLinkClick"><TextBlock Text="{Binding Path=CellValue}" /></Hyperlink></TextBlock></Border></DataTemplate>


By default, Focusable property of the Hyperlink is true. Hence, if I click I am able to get the click handler. But, not able to get the parent of the hyperlink i.e. theDataGridCell ?

_dataGrid.CurrentColumn is always null for me on hyperlink click. Moreover, since Hyperlink is not part of Visual I cannot traverse also ? How do I get theDataGridCell where this Hyperlink is hosted (in the run-time) ? 

NB:
Alternatively, if you suggest me to use a Button styled as a link button instead of Hyperlink, then the problem is that since my datagrid cell has the capability of going into Edit Mode,,, the button click event never gets raised.CurrentCellChanged event of the grid supersedes everything. Rather the cell goes into edit mode in this event.

But, with Hyperlink's Focusable=true, this issue at least is not there. But, again there are other issues as described above. 






Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>