/// <summary> /// Creates a GUI column from the given properties. /// </summary> /// <param name="pColumn">The column properties.</param> /// <param name="pIndex">The column index.</param> /// <returns>The created column.</returns> public static ExtendedGridViewColumn CreateFrom(TreeListViewColumn pColumn, int pIndex) { ExtendedGridViewColumn lColumn = new ExtendedGridViewColumn(); // Header. lColumn.Header = pColumn.Header; // Width. GridLength lWidth = new GridLength(); if (pColumn.Stretch) { lWidth = new GridLength(pColumn.Width, GridUnitType.Star); } else { lWidth = new GridLength(pColumn.Width, GridUnitType.Pixel); } lColumn.GridLength = lWidth; // Template selector. if (pColumn.TemplateSelector != null) { lColumn.CellTemplateSelector = pColumn.TemplateSelector; } else { // Template. lColumn.CellTemplate = XTreeListView.Resources.All.Instance.GetCellTemplate(pColumn.DisplayMemberPath); } return(lColumn); }
/// <summary> /// Sets the first column of the tree list view. /// </summary> /// <param name="pColumn">The first column properties.</param> public void SetFirstColumn(TreeListViewColumn pColumn) { this.Columns.CollectionChanged -= this.OnGridViewColumnsCollectionChanged; ExtendedGridViewColumn lColumn = ExtendedGridViewColumn.CreateFrom(pColumn, 0); if (this.Columns.Any()) { this.Columns.RemoveAt(0); } if (this.Columns.Any()) { this.Columns.Insert(0, lColumn); } else { this.Columns.Add(lColumn); } if (this.mGridViewColumnBackup.Any()) { this.mGridViewColumnBackup.RemoveAt(0); } if (this.mGridViewColumnBackup.Any()) { this.mGridViewColumnBackup.Insert(0, lColumn.Clone()); } else { this.mGridViewColumnBackup.Add(lColumn.Clone()); } this.UpdateColumns(); this.Columns.CollectionChanged += this.OnGridViewColumnsCollectionChanged; }
/// <summary> /// Adds a new column to the tree list view. /// </summary> /// <param name="pColumn">The column to add.</param> public void AddColumn(TreeListViewColumn pColumn) { this.Columns.CollectionChanged -= this.OnGridViewColumnsCollectionChanged; ExtendedGridViewColumn lColumn = ExtendedGridViewColumn.CreateFrom(pColumn, this.Columns.Count); this.Columns.Add(lColumn); this.mGridViewColumnBackup.Add(lColumn.Clone()); this.UpdateColumnHeaderVisibility(); this.Columns.CollectionChanged += this.OnGridViewColumnsCollectionChanged; }