0
votes

I have a DataGrid. In the DataGrid's AutoGeneratingColumn event I have some code that looks like this:

 if (e.Property.Name.Contains("MetaData"))
 {
                var descCol = new DataGridTextColumn(e.Property);
                var bnd = new Binding("Description");
                bnd.Mode = BindingMode.TwoWay;
                descCol.Binding = bnd;
                e.Column = descCol;
                e.Column.Header = "Description";
                return;
  }

The column binds to a type MetaData which has a string property named Description that I would like displayed in my DataGrid. So far I've been unable to get the value of the Description property to display in my DataGrid. I think the path I am passing into the Binding constructor might be incorrect. I've tried "MetaData.Description" as well and it doesn't work either.

Can anyone help me properly set up the binding on my DataGridTextColumn?

2

2 Answers

0
votes

Change this,

var bnd = new Binding("Description"); 

to

var bnd = new Binding(e.Property.Name);
0
votes

var bnd = new Binding("MetaData.Description");

Did the trick after I also solved this issue:

Entity Framework / RIA Services Include not working