Skip to content

Commit

Permalink
fixed an issue where cell selection wasnt working with active filter
Browse files Browse the repository at this point in the history
  • Loading branch information
w-ahmad committed Jul 2, 2024
1 parent d09f7ba commit 01a706b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 0 additions & 2 deletions src/WinUI.TableView/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ protected override void PrepareContainerForItemOverride(DependencyObject element

if (element is TableViewRow row)
{
var index = IndexFromContainer(element);
row.SetValue(TableViewRow.IndexProperty, index);
row.ApplyCellsSelectionState();

if (CurrentCellSlot.HasValue)
Expand Down
8 changes: 1 addition & 7 deletions src/WinUI.TableView/TableViewRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ private static void OnTableViewChanged(DependencyObject d, DependencyPropertyCha
}
}

private static void OnIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as TableViewRow)?.ApplyCellsSelectionState();
}

private void OnCellSelectionChanged(object? sender, TableViewCellSelectionChangedEvenArgs e)
{
if (e.OldSelection.Any(x => x.Row == Index) ||
Expand Down Expand Up @@ -194,15 +189,14 @@ internal void ApplyCellsSelectionState()

internal IList<TableViewCell> Cells => _cellPresenter?.Cells ?? new List<TableViewCell>();

public int Index => (int)GetValue(IndexProperty);
public int Index => TableView.IndexFromContainer(this);

public TableView TableView
{
get => (TableView)GetValue(TableViewProperty);
set => SetValue(TableViewProperty, value);
}

public static readonly DependencyProperty IndexProperty = DependencyProperty.Register(nameof(Index), typeof(int), typeof(TableViewRow), new PropertyMetadata(-1, OnIndexChanged));
public static readonly DependencyProperty TableViewProperty = DependencyProperty.Register(nameof(TableView), typeof(TableView), typeof(TableViewRow), new PropertyMetadata(default, OnTableViewChanged));
}

Expand Down

0 comments on commit 01a706b

Please sign in to comment.