@@ -500,28 +500,46 @@ internal void EnsureLayout()
500500 selectionIndicator = fontIcon ? . Parent as Border ;
501501 }
502502
503- if ( selectionIndicator is not null && IsSelected )
503+ if ( TableView is ListView { SelectionMode : ListViewSelectionMode . Multiple } )
504504 {
505- // Assign a TranslateTransform for animation
506- var _translateTransform = new TranslateTransform ( ) ;
507- selectionIndicator . RenderTransform = _translateTransform ;
508-
509- var toValue = Math . Round ( - detailsHeight / 2 ) ; // move up or down
505+ var fontIcon = this . FindDescendant < FontIcon > ( x => x . Glyph == Check_Mark ) ;
506+ selectionIndicator = fontIcon ? . Parent as Border ;
507+ }
510508
511- var animation = new DoubleAnimation
509+ if ( selectionIndicator is not null )
510+ {
511+ if ( IsSelected )
512512 {
513- To = toValue ,
514- Duration = new Duration ( TimeSpan . Zero )
515- } ;
513+ // Assign a TranslateTransform for animation
514+ var translateTransform = new TranslateTransform ( ) ;
515+ selectionIndicator . RenderTransform = translateTransform ;
516+
517+ var toValue = Math . Round ( - detailsHeight / 2 ) ; // move up or down
516518
517- var storyboard = new Storyboard ( ) ;
518- Storyboard . SetTarget ( animation , _translateTransform ) ;
519- Storyboard . SetTargetProperty ( animation , "Y" ) ; // vertical movement
520- storyboard . Children . Add ( animation ) ;
519+ var animation = new DoubleAnimation
520+ {
521+ To = toValue ,
522+ Duration = new Duration ( TimeSpan . Zero )
523+ } ;
521524
522- storyboard . Begin ( ) ;
525+ var storyboard = new Storyboard ( ) ;
526+ Storyboard . SetTarget ( animation , translateTransform ) ;
527+ Storyboard . SetTargetProperty ( animation , "Y" ) ; // vertical movement
528+ storyboard . Children . Add ( animation ) ;
529+
530+ storyboard . Begin ( ) ;
531+ }
532+ else
533+ {
534+ // Row is not selected → reset any previous offset
535+ if ( selectionIndicator . RenderTransform is TranslateTransform tt )
536+ tt . Y = 0 ;
537+ else
538+ selectionIndicator . RenderTransform = null ;
539+ }
523540 }
524541
542+
525543 _selectionBackground ??= _itemPresenter ? . FindDescendants ( )
526544 . OfType < Border > ( )
527545 . FirstOrDefault ( x => x . Name is not Selection_Background && x . Margin == _selectionBackgroundMargin ) ;
0 commit comments