@@ -48,35 +48,22 @@ public TableViewRow()
4848 RegisterPropertyChangedCallback ( BackgroundProperty , delegate { OnBackgroundChanged ( ) ; } ) ;
4949 }
5050
51- #if WINDOWS
52- /// <summary>
53- /// Handles the ContextRequested event.
54- /// </summary>
55- private void OnContextRequested ( UIElement sender , ContextRequestedEventArgs args )
51+ #if ! WINDOWS
52+ protected override void OnRightTapped ( RightTappedRoutedEventArgs e )
5653 {
57- if ( args . TryGetPosition ( sender , out var position ) )
58- {
59- if ( IsContextRequestedFromCell ( position ) && TableView ? . CellContextFlyout is not null ) return ;
60-
61- TableView ? . ShowRowContext ( this , position ) ;
62- }
63- }
54+ base . OnRightTapped ( e ) ;
6455
56+ var position = e . GetPosition ( this ) ;
57+ #else
6558 /// <summary>
66- /// Determines if the context request is from a cell .
59+ /// Handles the ContextRequested event .
6760 /// </summary>
68- private bool IsContextRequestedFromCell ( Windows . Foundation . Point position )
61+ private void OnContextRequested ( UIElement sender , ContextRequestedEventArgs e )
6962 {
70- if ( CellPresenter is null ) return false ;
71-
72- var transform = CellPresenter . TransformToVisual ( this ) . Inverse ;
73- var point = transform . TransformPoint ( position ) ;
74- var transformedPoint = CellPresenter . TransformToVisual ( null ) . TransformPoint ( point ) ;
75- return VisualTreeHelper . FindElementsInHostCoordinates ( transformedPoint , CellPresenter )
76- . OfType < TableViewCell > ( )
77- . Any ( ) ;
78- }
63+ if ( ! e . TryGetPosition ( sender , out var position ) ) return ;
7964#endif
65+ e . Handled = TableView ? . ShowRowContext ( this , position ) is true ;
66+ }
8067
8168 /// <summary>
8269 /// Handles the IsSelected property changed.
@@ -173,10 +160,10 @@ protected override void OnContentChanged(object oldContent, object newContent)
173160 else
174161 {
175162#endif
176- foreach ( var cell in Cells )
177- {
178- cell . RefreshElement ( ) ;
179- }
163+ foreach ( var cell in Cells )
164+ {
165+ cell . RefreshElement ( ) ;
166+ }
180167#if WINDOWS
181168 }
182169#endif
@@ -510,14 +497,14 @@ internal void EnsureLayout()
510497#endif
511498 : new Thickness ( 20 , 0 , 16 , 0 ) ;
512499#if ! WINDOWS
513- var multiSelectSquare = this . FindDescendant < Border > ( x => x . Name is "MultiSelectSquare" ) ;
514- if ( multiSelectSquare is not null )
515- {
516- multiSelectSquare . Opacity = 0.5 ;
517- multiSelectSquare. CornerRadius = new CornerRadius ( 4 ) ;
518- multiSelectSquare. BorderThickness = new Thickness ( 1 ) ;
519- multiSelectSquare. Margin = new Thickness ( 10 , 0 , 0 , 0 ) ;
520- }
500+ var multiSelectSquare = this . FindDescendant < Border > ( x => x . Name is "MultiSelectSquare" ) ;
501+ if ( multiSelectSquare is not null )
502+ {
503+ multiSelectSquare . Opacity = 0.5 ;
504+ multiSelectSquare. CornerRadius = new CornerRadius ( 4 ) ;
505+ multiSelectSquare. BorderThickness = new Thickness ( 1 ) ;
506+ multiSelectSquare. Margin = new Thickness ( 10 , 0 , 0 , 0 ) ;
507+ }
521508#endif
522509 }
523510 }
0 commit comments