I am trying to create a series of related columns in a RadGridView, and I am using a template to create hyperlinks in two columns. Here is basically what I have:
<telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Distributor" DataContext="{Binding Distributor}" CellTemplate="{StaticResource linkTemplate}"/>
and
<DataTemplate x:Key="linkTemplate"> <TextBlock> <Hyperlink DataContext={TemplateBinding DataContext} Click="Hyperlink_Click"> <TextBlock Text="{Binding Name}" /> </Hyperlink> </TextBlock> </DataTemplate>
RadGridView itself is associated with a set of DistributorContainer objects, which, among other things, have the Distributor property. The linkTemplate link refers directly to the properties of the Distributor object, so the datacontext hyperlink must be installed on the Distributor.
Unfortunately, the hyperlink data context is a DistributorContainer object. I use linkTemplate (as well as the Hyperlink_Click handler) in lists that bind to Distributor lists, and I would really like to reuse this template because it is basically the same.
Why does the template not get the Distributor as its DataContext through the TemplateBinding for the GridViewDataColumn?
c # data-binding telerik wpf datatemplate
Jake
source share