DataGridComboBoxColumn - TextBlock is empty

Oct 2, 2008 at 11:43 AM
When manually creating ComboBox columns in code and binding them to custom reference types - they do not have any display when not in edit-mode.

When in editmode they display correctly.

How do I create a CellStyle in code to bind to the ToString() of the object?
Coordinator
Oct 2, 2008 at 12:31 PM
Could you provide a code snippet of your DataGridComboBoxColumn.
Oct 2, 2008 at 12:47 PM
public class Order
{
public Customer{get;set;}
...
}
public class Customer
{
public string Name{get;set;}
public override string ToString()
{
return Name;
}
}

            var _column = new DataGridComboBoxColumn();
            _column.Header = "Customer";
            var dataFieldBinding = new Binding("Customer");
            dataFieldBinding.Mode = BindingMode.TwoWay;
            _column.DataFieldBinding = dataFieldBinding;

            _column.ItemsSource = //some list of Customers

Coordinator
Oct 2, 2008 at 2:00 PM
DataFieldTarget may help.  For more information on DataGridComboBoxColumn usage see these blog posts, http://blogs.msdn.com/vinsibal/archive/2008/08/26/wpf-datagrid-working-with-datagridcomboboxcolumn.aspx and http://blogs.msdn.com/vinsibal/archive/2008/08/28/wpf-datagrid-working-with-datagridcomboboxcolumns-part-2.aspx.
Oct 2, 2008 at 6:40 PM
DataFieldTarget may have helped if I had been binding to a property on Customer - but here I'm binding to the object it self. I guess I have to create a DataTemplate instead.

Thanks for your time anyhow.