@@ -127,7 +127,6 @@ protected override void OnPreviewKeyDown(KeyRoutedEventArgs e)
127127
128128 if ( isEditing && currentCell is not null )
129129 {
130- currentCell . SetElement ( ) ;
131130 currentCell = GetCellFromSlot ( newSlot ) ;
132131 currentCell . PrepareForEdit ( ) ;
133132 }
@@ -655,9 +654,10 @@ internal async void SelectCells(TableViewCellSlot slot, bool shiftKey, bool ctrl
655654 SelectedCellRanges . Remove ( selectionRange ) ;
656655 selectionRange . Clear ( ) ;
657656 SelectionStartCellSlot ??= CurrentCellSlot ;
657+ SelectionStartCellSlot ??= slot ;
658658 if ( shiftKey && SelectionMode is ListViewSelectionMode . Multiple or ListViewSelectionMode . Extended )
659659 {
660- var currentSlot = SelectionStartCellSlot ?? slot ;
660+ var currentSlot = SelectionStartCellSlot . Value ;
661661 var startRow = Math . Min ( slot . Row , currentSlot . Row ) ;
662662 var endRow = Math . Max ( slot . Row , currentSlot . Row ) ;
663663 var startCol = Math . Min ( slot . Column , currentSlot . Column ) ;
@@ -677,7 +677,7 @@ internal async void SelectCells(TableViewCellSlot slot, bool shiftKey, bool ctrl
677677 }
678678 else
679679 {
680- SelectionStartCellSlot = null ;
680+ SelectionStartCellSlot = slot ;
681681 selectionRange . Add ( slot ) ;
682682
683683 if ( SelectedCellRanges . LastOrDefault ( x => x . Contains ( slot ) ) is { } range )
@@ -713,6 +713,8 @@ internal void DeselectCell(TableViewCellSlot slot)
713713 internal void SetCurrentCell ( TableViewCellSlot ? slot )
714714 {
715715 var oldSlot = CurrentCellSlot ;
716+ var currentCell = oldSlot . HasValue ? GetCellFromSlot ( oldSlot . Value ) : default ;
717+ currentCell ? . SetElement ( ) ;
716718 CurrentCellSlot = slot ;
717719 CurrentCellChanged ? . Invoke ( this , new TableViewCurrentCellChangedEventArgs ( oldSlot , slot ) ) ;
718720 }
@@ -832,7 +834,7 @@ void ViewChanged(object? _, ScrollViewerViewChangedEventArgs e)
832834 return default ;
833835 }
834836
835- private TableViewCell GetCellFromSlot ( TableViewCellSlot slot )
837+ internal TableViewCell GetCellFromSlot ( TableViewCellSlot slot )
836838 {
837839 return ContainerFromIndex ( slot . Row ) is TableViewRow row ? row . Cells [ slot . Column ] : default ! ;
838840 }
0 commit comments