SL4 - Binding DataGridTextColumn to a property

Posted by Brent on Stack Overflow See other posts from Stack Overflow or by Brent
Published on 2011-03-16T16:34:42Z Indexed on 2011/03/17 16:10 UTC
Read the original article Hit count: 344

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?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about datagridtextcolumn