@@ -158,7 +158,7 @@ private void HandleNavigations(KeyRoutedEventArgs e, bool shiftKey, bool ctrlKey
158
158
else if ( ( e . Key is VirtualKey . Left or VirtualKey . Right or VirtualKey . Up or VirtualKey . Down )
159
159
&& ! IsEditing )
160
160
{
161
- var row = ( SelectionUnit is TableViewSelectionUnit . Row ? SelectionStartRowIndex : SelectionStartCellSlot ? . Row ) ?? - 1 ;
161
+ var row = ( LastSelectionUnit is TableViewSelectionUnit . Row ? SelectionStartRowIndex : SelectionStartCellSlot ? . Row ) ?? - 1 ;
162
162
var column = CurrentCellSlot ? . Column ?? - 1 ;
163
163
164
164
if ( row == - 1 && column == - 1 )
@@ -168,6 +168,11 @@ private void HandleNavigations(KeyRoutedEventArgs e, bool shiftKey, bool ctrlKey
168
168
else if ( e . Key is VirtualKey . Left or VirtualKey . Right )
169
169
{
170
170
column = e . Key is VirtualKey . Left ? ctrlKey ? 0 : column - 1 : ctrlKey ? Columns . VisibleColumns . Count - 1 : column + 1 ;
171
+ if ( column >= Columns . VisibleColumns . Count )
172
+ {
173
+ column = 0 ;
174
+ row ++ ;
175
+ }
171
176
}
172
177
else
173
178
{
@@ -612,11 +617,6 @@ internal void ClearFilters()
612
617
}
613
618
}
614
619
615
- private bool IsValidSlot ( TableViewCellSlot slot )
616
- {
617
- return slot . Row >= 0 && slot . Column >= 0 && slot . Row < Items . Count && slot . Column < Columns . VisibleColumns . Count ;
618
- }
619
-
620
620
internal new void SelectAll ( )
621
621
{
622
622
if ( IsEditing )
@@ -703,7 +703,7 @@ private void DeselectAllCells()
703
703
704
704
internal void MakeSelection ( TableViewCellSlot slot , bool shiftKey , bool ctrlKey = false )
705
705
{
706
- if ( slot . Row < 0 || slot . Row >= Items . Count )
706
+ if ( ! slot . IsValidRow ( this ) )
707
707
{
708
708
return ;
709
709
}
@@ -725,13 +725,17 @@ internal void MakeSelection(TableViewCellSlot slot, bool shiftKey, bool ctrlKey
725
725
}
726
726
}
727
727
728
- if ( SelectionUnit is TableViewSelectionUnit . Row )
728
+ if ( SelectionUnit is TableViewSelectionUnit . Row
729
+ || ( LastSelectionUnit is TableViewSelectionUnit . Row && slot . IsValidRow ( this ) && ! slot . IsValidColumn ( this ) )
730
+ || ( SelectionUnit is TableViewSelectionUnit . CellOrRow && slot . IsValidRow ( this ) && ! slot . IsValidColumn ( this ) ) )
729
731
{
730
732
SelectRows ( slot , shiftKey ) ;
733
+ LastSelectionUnit = TableViewSelectionUnit . Row ;
731
734
}
732
735
else
733
736
{
734
737
SelectCells ( slot , shiftKey ) ;
738
+ LastSelectionUnit = TableViewSelectionUnit . Cell ;
735
739
}
736
740
}
737
741
else if ( ! IsReadOnly )
@@ -771,7 +775,7 @@ private void SelectRows(TableViewCellSlot slot, bool shiftKey)
771
775
}
772
776
}
773
777
774
- if ( ! IsReadOnly && IsValidSlot ( slot ) )
778
+ if ( ! IsReadOnly && slot . IsValid ( this ) )
775
779
{
776
780
DispatcherQueue . TryEnqueue ( ( ) => SetCurrentCell ( slot ) ) ;
777
781
}
@@ -787,7 +791,7 @@ private void SelectRows(TableViewCellSlot slot, bool shiftKey)
787
791
788
792
private void SelectCells ( TableViewCellSlot slot , bool shiftKey )
789
793
{
790
- if ( ! IsValidSlot ( slot ) )
794
+ if ( ! slot . IsValid ( this ) )
791
795
{
792
796
return ;
793
797
}
@@ -896,7 +900,7 @@ private void OnCellSelectionChanged()
896
900
897
901
internal async Task < TableViewCell > ScrollCellIntoView ( TableViewCellSlot slot )
898
902
{
899
- if ( _scrollViewer is null || ! IsValidSlot ( slot ) ) return default ! ;
903
+ if ( _scrollViewer is null || ! slot . IsValid ( this ) ) return default ! ;
900
904
901
905
var row = await ScrollRowIntoView ( slot . Row ) ;
902
906
var ( start , end ) = GetColumnsInDisplay ( ) ;
@@ -1007,7 +1011,7 @@ void ViewChanged(object? _, ScrollViewerViewChangedEventArgs e)
1007
1011
1008
1012
internal TableViewCell GetCellFromSlot ( TableViewCellSlot slot )
1009
1013
{
1010
- return IsValidSlot ( slot ) && ContainerFromIndex ( slot . Row ) is TableViewRow row ? row . Cells [ slot . Column ] : default ! ;
1014
+ return slot . IsValid ( this ) && ContainerFromIndex ( slot . Row ) is TableViewRow row ? row . Cells [ slot . Column ] : default ! ;
1011
1015
}
1012
1016
1013
1017
private ( int start , int end ) GetColumnsInDisplay ( )
0 commit comments