Question

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?

Was it helpful?

Solution 2

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

Did the trick after I also solved this issue:

Entity Framework / RIA Services Include not working

OTHER TIPS

Change this,

var bnd = new Binding("Description"); 

to

var bnd = new Binding(e.Property.Name);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top