From 01a706b3ebc5d91e479e22df29c8eedbe40a145d Mon Sep 17 00:00:00 2001 From: Waheed Ahmad Date: Tue, 2 Jul 2024 16:14:41 +0500 Subject: [PATCH] fixed an issue where cell selection wasnt working with active filter --- src/WinUI.TableView/TableView.cs | 2 -- src/WinUI.TableView/TableViewRow.cs | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/WinUI.TableView/TableView.cs b/src/WinUI.TableView/TableView.cs index c86ac34..c5cb1d6 100644 --- a/src/WinUI.TableView/TableView.cs +++ b/src/WinUI.TableView/TableView.cs @@ -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) diff --git a/src/WinUI.TableView/TableViewRow.cs b/src/WinUI.TableView/TableViewRow.cs index 133d33b..ea983d7 100644 --- a/src/WinUI.TableView/TableViewRow.cs +++ b/src/WinUI.TableView/TableViewRow.cs @@ -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) || @@ -194,7 +189,7 @@ internal void ApplyCellsSelectionState() internal IList Cells => _cellPresenter?.Cells ?? new List(); - public int Index => (int)GetValue(IndexProperty); + public int Index => TableView.IndexFromContainer(this); public TableView TableView { @@ -202,7 +197,6 @@ public TableView TableView 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)); }