I am binding a blank WPF gridview object to columns in a table at runtime using C# Binding and GridViewColumnobjects to manipulate the gridview. I need one type of column to have TextWrapping turned on, and I cannot seem to find the right method.
System.Windows.Controls.GridViewColumn gvc;
System.Windows.Data.Binding binding;
gView.Columns.Clear();
foreach (DataColumn column in dt.Columns)
{
gvc = new System.Windows.Controls.GridViewColumn();
binding = new System.Windows.Data.Binding();
binding.Path = new PropertyPath(column.ColumnName);
binding.Mode = BindingMode.OneWay;
gvc.Header = column.Caption;
switch (column.ColumnName)
{
case "Unit":
gvc.Width = 60;
break;
case "Message":
gvc.Width = 600;
break;
case "Notes":
gvc.Width = 700;
//--THIS IS WHERE IS WANT TO SET gvc.TextWrapping="Wrap";
break;
}
gvc.DisplayMemberBinding = binding;
gView.Columns.Add(gvc);
}