@@ -723,20 +723,20 @@ private void ShowSuggestionsPopup(bool show)
723
723
724
724
private void UpdatePopupWidth ( )
725
725
{
726
- if ( this . _suggestionsList == null )
726
+ if ( this . _suggestionsContainer == null )
727
727
{
728
728
return ;
729
729
}
730
730
731
731
if ( this . PopupPlacement == SuggestionPopupPlacementMode . Attached )
732
732
{
733
- this . _suggestionsList . MaxWidth = double . PositiveInfinity ;
734
- this . _suggestionsList . Width = this . _richEditBox . ActualWidth ;
733
+ this . _suggestionsContainer . MaxWidth = double . PositiveInfinity ;
734
+ this . _suggestionsContainer . Width = this . _richEditBox . ActualWidth ;
735
735
}
736
736
else
737
737
{
738
- this . _suggestionsList . MaxWidth = this . _richEditBox . ActualWidth ;
739
- this . _suggestionsList . Width = double . NaN ;
738
+ this . _suggestionsContainer . MaxWidth = this . _richEditBox . ActualWidth ;
739
+ this . _suggestionsContainer . Width = double . NaN ;
740
740
}
741
741
}
742
742
@@ -745,6 +745,11 @@ private void UpdatePopupWidth()
745
745
/// </summary>
746
746
private void UpdatePopupOffset ( )
747
747
{
748
+ if ( this . _suggestionsContainer == null || this . _suggestionPopup == null || this . _richEditBox == null )
749
+ {
750
+ return ;
751
+ }
752
+
748
753
this . _richEditBox . TextDocument . Selection . GetRect ( PointOptions . None , out var selectionRect , out _ ) ;
749
754
Thickness padding = this . _richEditBox . Padding ;
750
755
selectionRect . X -= HorizontalOffset ;
@@ -762,7 +767,7 @@ private void UpdatePopupOffset()
762
767
{
763
768
var normalizedX = selectionRect . X / editBoxWidth ;
764
769
this . _suggestionPopup . HorizontalOffset =
765
- ( this . _richEditBox . ActualWidth - this . _suggestionsList . ActualWidth ) * normalizedX ;
770
+ ( this . _richEditBox . ActualWidth - this . _suggestionsContainer . ActualWidth ) * normalizedX ;
766
771
}
767
772
}
768
773
@@ -777,10 +782,10 @@ private void UpdatePopupOffset()
777
782
778
783
if ( this . _suggestionPopup . VerticalOffset == 0 )
779
784
{
780
- if ( IsElementOnScreen ( this . _suggestionsList , offsetY : downOffset ) &&
781
- ( IsElementInsideWindow ( this . _suggestionsList , offsetY : downOffset ) ||
782
- ! IsElementInsideWindow ( this . _suggestionsList , offsetY : upOffset ) ||
783
- ! IsElementOnScreen ( this . _suggestionsList , offsetY : upOffset ) ) )
785
+ if ( IsElementOnScreen ( this . _suggestionsContainer , offsetY : downOffset ) &&
786
+ ( IsElementInsideWindow ( this . _suggestionsContainer , offsetY : downOffset ) ||
787
+ ! IsElementInsideWindow ( this . _suggestionsContainer , offsetY : upOffset ) ||
788
+ ! IsElementOnScreen ( this . _suggestionsContainer , offsetY : upOffset ) ) )
784
789
{
785
790
this . _suggestionPopup . VerticalOffset = downOffset ;
786
791
this . _popupOpenDown = true ;
0 commit comments