//------------------------------------------------------------------- // // Internal Methods / Properties // //------------------------------------------------------------------- #region Internal Methods /// <summary> /// process the column collection chagned event /// </summary> internal virtual void OnColumnCollectionChanged(GridViewColumnCollectionChangedEventArgs e) { if (DesiredWidthList != null) { if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { // NOTE: The steps to make DesiredWidthList.Count <= e.ActualIndex // // 1. init with 3 auto columns; // 2. add 1 column to the column collection with width 90.0; // 3. remove the column we jsut added to the the collection; // // Now we have DesiredWidthList.Count equals to 3 while the removed column // has ActualIndex equals to 3. // if (DesiredWidthList.Count > e.ActualIndex) { DesiredWidthList.RemoveAt(e.ActualIndex); } } else if (e.Action == NotifyCollectionChangedAction.Reset) { DesiredWidthList = null; } } }
/// <summary> /// ensure ShareStateList have at least columns.Count items /// </summary> internal void EnsureDesiredWidthList() { GridViewColumnCollection columns = Columns; if (columns != null) { int count = columns.Count; if (DesiredWidthList == null) { DesiredWidthList = new List <double>(count); } int c = count - DesiredWidthList.Count; for (int i = 0; i < c; i++) { DesiredWidthList.Add(Double.NaN); } } }