/// <summary> /// Manages the expand states. /// </summary> /// <param name="targetColumn">The target column.</param> public void ManageExpandStates(IDetailColumn targetColumn = null) { SpreadsheetView spreadsheet = null; if (targetColumn == null) { targetColumn = ParentColumn as IDetailColumn; spreadsheet = ParentSpreadsheet ?? this; } else { spreadsheet = targetColumn.Owner; } if (spreadsheet.ItemsSource == null || ((IList)spreadsheet.ItemsSource).Count == 0) { spreadsheet._childSpreadsheets.Clear(); if (spreadsheet.Columns != null) { foreach (IDetailColumn column in spreadsheet.Columns.Where(x => x is IDetailColumn)) { column.IsExpanded = false; column.CanExpand = false; } } } else { if (targetColumn != null && spreadsheet != null) { var collapseColumn = !GetTopLevelSpreadsheet().GetAllChildSpreadsheets() .Where(x => x.ParentColumn == targetColumn) .Any(x => x.IsVisible || (x.ParentCell.ContainedValue != null && x.Columns.Any())); if (collapseColumn) { targetColumn.IsExpanded = false; targetColumn.CanExpand = false; } else { if (!targetColumn.IsExpanded && !targetColumn.CanExpand) targetColumn.IsExpanded = true; targetColumn.CanExpand = true; } } } }
/// <summary> /// Switches the visibility including children. /// </summary> /// <param name="column">The column.</param> public void SwitchVisibilityIncludingChildren(IDetailColumn column) { if (ParentColumn != column) foreach (var spreadsheet in _childSpreadsheets) { spreadsheet.SwitchVisibilityIncludingChildren(column); } else SwitchVisibility(); }