I\'ve a GridView
which has RowDetail
. I want to each time user clicks on the rows get some detail from database, I use Telerik GridView
I've even simplified the accepted solution. It uses the trick that from DataTemplates, you can reference static resources. And in static resources, you can use ElementName in binding.
Create a new control:
public class ElementProxy : DependencyObject
{
public DependencyObject Element
{
get { return (DependencyObject)GetValue(ElementProperty); }
set { SetValue(ElementProperty, value); }
}
public static readonly DependencyProperty ElementProperty =
DependencyProperty.Register("Element", typeof(DependencyObject), typeof(ElementProxy), new PropertyMetadata(null));
}
Put it into static resources of the DataGrid or its parent control and reference it through StaticResource:
(in column template:)