Search code examples
c#wpfdatagrid

how to create a attached property of BindingBase Type and receive value from binding expression


the requirement is to export data from datagrid to excel file, but for datagridtemplatecolumn it's not reasonable to export the content. To solve this problem, I tried to add a attached property on datagridtemplatecolumn, the type of the property is bindingbase, so i can use the bindingbase object to get a value from the datacontext to export.

The attached property is similar to DataGridTextColumn.Binding,but it seems not possible to assign value to the property with "{Binding xxx}" expression.

So, is it possible to create an attached property of BindingBase Type? Or if there is another way to solve my problem?


Solution

  • I add a ExportPropertyPath Attached property to the DataGridColumn, which solved this problem.