AmazonScrape.DataGridPlus.AddColumn C# (CSharp) Method

AddColumn() private method

private AddColumn ( System.Windows.FrameworkElementFactory ef, int widthPercent, string headerText, string sortOn = "", System.Windows.Style style = null ) : void
ef System.Windows.FrameworkElementFactory
widthPercent int
headerText string
sortOn string
style System.Windows.Style
return void
        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);
        }