@@ -53,7 +53,7 @@ public CompletionWindow(TextArea textArea) : base(textArea)
5353 Child = CompletionList ;
5454 // prevent user from resizing window to 0x0
5555 MinHeight = 15 ;
56- MinWidth = 30 ;
56+ MinWidth = 30 ;
5757
5858 _toolTipContent = new ContentControl ( ) ;
5959 _toolTipContent . Classes . Add ( "ToolTip" ) ;
@@ -62,7 +62,7 @@ public CompletionWindow(TextArea textArea) : base(textArea)
6262 {
6363 IsLightDismissEnabled = true ,
6464 PlacementTarget = this ,
65- Placement = PlacementMode . Right ,
65+ Placement = PlacementMode . RightEdgeAlignedTop ,
6666 Child = _toolTipContent ,
6767 } ;
6868
@@ -104,25 +104,30 @@ private void CompletionList_SelectionChanged(object sender, SelectionChangedEven
104104 } ;
105105 }
106106 else
107- {
107+ {
108108 _toolTipContent . Content = description ;
109109 }
110110
111111 _toolTip . IsOpen = false ; //Popup needs to be closed to change position
112112
113- //Calculate offset for tooltip
113+ // Calculate offset for tooltip
114+ var popupRoot = Host as PopupRoot ;
114115 if ( CompletionList . CurrentList != null )
115116 {
116- int index = CompletionList . CurrentList . IndexOf ( item ) ;
117- int scrollIndex = ( int ) CompletionList . ListBox . Scroll . Offset . Y ;
118- int yoffset = index - scrollIndex ;
119- if ( yoffset < 0 ) yoffset = 0 ;
120- if ( ( yoffset + 1 ) * 20 > MaxHeight ) yoffset -- ;
121- _toolTip . Offset = new PixelPoint ( 2 , yoffset * 20 ) ; //Todo find way to measure item height
117+ double yOffset = 0 ;
118+ var itemContainer = CompletionList . ListBox . ContainerFromItem ( item ) ;
119+ if ( popupRoot != null && itemContainer != null )
120+ {
121+ var position = itemContainer . TranslatePoint ( new Point ( 0 , 0 ) , popupRoot ) ;
122+ if ( position . HasValue )
123+ yOffset = position . Value . Y ;
124+ }
125+
126+ _toolTip . Offset = new Point ( 2 , yOffset ) ;
122127 }
123128
124- _toolTip . PlacementTarget = this . Host as PopupRoot ;
125- _toolTip . IsOpen = true ;
129+ _toolTip . PlacementTarget = popupRoot ;
130+ _toolTip . IsOpen = true ;
126131 }
127132 else
128133 {
0 commit comments