Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 110 additions & 1 deletion src/TableView.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,26 @@
/// </summary>
public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false));

/// <summary>
Comment thread
JanviMahajan14 marked this conversation as resolved.
Outdated
/// Identifies the <see cref="GroupByPath"/> dependency property.
/// </summary>
public static readonly DependencyProperty GroupByPathProperty = DependencyProperty.Register(nameof(GroupByPath), typeof(string), typeof(TableView), new PropertyMetadata(null, OnGroupByPathChanged));

/// <summary>
/// Identifies the <see cref="ShowGroupHeaders"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowGroupHeadersProperty = DependencyProperty.Register(nameof(ShowGroupHeaders), typeof(bool), typeof(TableView), new PropertyMetadata(true, OnShowGroupHeadersChanged));

/// <summary>
/// Identifies the <see cref="GroupSortDirection"/> dependency property.
/// </summary>
public static readonly DependencyProperty GroupSortDirectionProperty = DependencyProperty.Register(nameof(GroupSortDirection), typeof(SortDirection), typeof(TableView), new PropertyMetadata(SortDirection.Ascending, OnGroupSortDirectionChanged));

/// <summary>
/// Identifies the <see cref="ShowGroupItemCount"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowGroupItemCountProperty = DependencyProperty.Register(nameof(ShowGroupItemCount), typeof(bool), typeof(TableView), new PropertyMetadata(true, OnShowGroupItemCountChanged));

/// <summary>
/// Gets or sets a value indicating whether opening the column filter over header right-click is enabled.
/// </summary>
Expand All @@ -281,7 +301,43 @@
/// <summary>
/// Gets the collection of sort descriptions applied to the items.
/// </summary>
Comment thread
JanviMahajan14 marked this conversation as resolved.
/// <summary>
/// Gets or sets the property path used to group items in the TableView.
/// </summary>
public string? GroupByPath
{
get => (string?)GetValue(GroupByPathProperty);
set => SetValue(GroupByPathProperty, value);
}

/// <summary>
/// Gets or sets a value indicating whether group headers are shown.
/// </summary>
public bool ShowGroupHeaders
{
get => (bool)GetValue(ShowGroupHeadersProperty);
set => SetValue(ShowGroupHeadersProperty, value);
}

/// <summary>
/// Gets or sets the sorting direction used for grouping.
/// </summary>
public SortDirection GroupSortDirection
{
get => (SortDirection)GetValue(GroupSortDirectionProperty);
set => SetValue(GroupSortDirectionProperty, value);
}

/// <summary>
/// Gets or sets a value indicating whether group headers show item counts.
/// </summary>
public bool ShowGroupItemCount
{
get => (bool)GetValue(ShowGroupItemCountProperty);
set => SetValue(ShowGroupItemCountProperty, value);
}

public IList<SortDescription> SortDescriptions => _collectionView.SortDescriptions;

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

Check failure on line 340 in src/TableView.Properties.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'TableView.SortDescriptions'

/// <summary>
/// Gets the collection of filter descriptions applied to the items.
Expand Down Expand Up @@ -1097,12 +1153,65 @@
}
}

/// <summary>
/// Handles changes to the GroupByPath property.
/// </summary>
private static void OnGroupByPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureGroupingSortDescription();
tableView.RebuildDisplayedItems();
}
}

/// <summary>
/// Handles changes to the ShowGroupHeaders property.
/// </summary>
private static void OnShowGroupHeadersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.RebuildDisplayedItems();
}
}

/// <summary>
/// Handles changes to the GroupSortDirection property.
/// </summary>
private static void OnGroupSortDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureGroupingSortDescription();
tableView.RebuildDisplayedItems();
}
}

/// <summary>
/// Handles changes to the ShowGroupItemCount property.
/// </summary>
private static void OnShowGroupItemCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.RebuildDisplayedItems();
}
}

/// <summary>
/// Throws an exception if the base ItemsSource property is set directly.
/// </summary>
private void OnBaseItemsSourceChanged(DependencyObject sender, DependencyProperty dp)
{
throw new InvalidOperationException("Setting this property directly is not allowed. Use TableView.ItemsSource instead.");
if (_isUpdatingBaseItemsSource || ReferenceEquals(base.ItemsSource, _displayItems))
{
return;
}

_isUpdatingBaseItemsSource = true;
base.ItemsSource = _displayItems;
_isUpdatingBaseItemsSource = false;
}

/// <summary>
Expand Down
Loading
Loading