/// <summary> /// Expands the given item. /// </summary> /// <param name="item">The item.</param> public void ExpandItem(object item) { if (this.DataGridOwner != null && this.IsItemExpandable(item)) { TextBlock expander = LayoutHelper.FindVisualChild <TextBlock>(this.GetCellContent(item)); expander.Text = "-"; this.DataGridOwner.SetDetailsVisibilityForItem(item, Visibility.Visible); if (this.RememberExpandedRows) { this.expandedItems.Add(item); } this.OnItemExpanded(item); } }
/// <summary> /// Collapses the given item. /// </summary> /// <param name="item">The item.</param> public void CollapseItem(object item) { if (this.DataGridOwner != null) { TextBlock expander = LayoutHelper.FindVisualChild <TextBlock>(this.GetCellContent(item)); expander.Text = "+"; this.DataGridOwner.SetDetailsVisibilityForItem(item, Visibility.Collapsed); if (this.RememberExpandedRows && this.expandedItems.Contains(item)) { this.expandedItems.Remove(item); } this.OnItemCollapsed(item); } }
/// <summary> /// Refreshes the attributes of each row that define whether that row is expandable or not. /// </summary> public void RefreshExpandableAttributes() { if (this.DataGridOwner != null) { foreach (var item in this.DataGridOwner.Items) { FrameworkElement content = this.GetCellContent(item); if (content != null) { TextBlock expansionTrigger = LayoutHelper.FindVisualChild <TextBlock>(content); if (expansionTrigger != null) { this.RefreshExpandableAttribute(expansionTrigger); } } } } }