private void AddColumn(FrameworkElementFactory ef,int widthPercent,string headerText,string sortOn = "",Style style=null)
{
// If overriding the default style
// TODO: test this
if (!(style == null)) ef.SetValue(StyleProperty, style);
DataGridTemplateColumn newCol = new DataGridTemplateColumn();
if (sortOn.Length > 0)
{
newCol.CanUserSort = true;
newCol.SortMemberPath = sortOn;
}
newCol.Header = headerText;
newCol.Width = new DataGridLength(widthPercent, DataGridLengthUnitType.Star);
DataTemplate template = new DataTemplate();
template.VisualTree = ef;
newCol.CellTemplate = template;
this.Columns.Add(newCol);
}