Silverlight DataBinding Error

后端 未结 2 847
予麋鹿
予麋鹿 2021-01-16 17:22

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

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-16 17:36

    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.

    1. 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));
      }
      
    2. Put it into static resources of the DataGrid or its parent control and reference it through StaticResource:

      
          
      
      

    (in column template:)

        
            
        
    

提交回复
热议问题