Skip to content

Commit b39d0ba

Browse files
committed
modify size of suggestionsContainer instead of the actual listview
1 parent 1f3dcc7 commit b39d0ba

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Input/RichSuggestBox/RichSuggestBox.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,20 +723,20 @@ private void ShowSuggestionsPopup(bool show)
723723

724724
private void UpdatePopupWidth()
725725
{
726-
if (this._suggestionsList == null)
726+
if (this._suggestionsContainer == null)
727727
{
728728
return;
729729
}
730730

731731
if (this.PopupPlacement == SuggestionPopupPlacementMode.Attached)
732732
{
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;
735735
}
736736
else
737737
{
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;
740740
}
741741
}
742742

@@ -745,6 +745,11 @@ private void UpdatePopupWidth()
745745
/// </summary>
746746
private void UpdatePopupOffset()
747747
{
748+
if (this._suggestionsContainer == null || this._suggestionPopup == null || this._richEditBox == null)
749+
{
750+
return;
751+
}
752+
748753
this._richEditBox.TextDocument.Selection.GetRect(PointOptions.None, out var selectionRect, out _);
749754
Thickness padding = this._richEditBox.Padding;
750755
selectionRect.X -= HorizontalOffset;
@@ -762,7 +767,7 @@ private void UpdatePopupOffset()
762767
{
763768
var normalizedX = selectionRect.X / editBoxWidth;
764769
this._suggestionPopup.HorizontalOffset =
765-
(this._richEditBox.ActualWidth - this._suggestionsList.ActualWidth) * normalizedX;
770+
(this._richEditBox.ActualWidth - this._suggestionsContainer.ActualWidth) * normalizedX;
766771
}
767772
}
768773

@@ -777,10 +782,10 @@ private void UpdatePopupOffset()
777782

778783
if (this._suggestionPopup.VerticalOffset == 0)
779784
{
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)))
784789
{
785790
this._suggestionPopup.VerticalOffset = downOffset;
786791
this._popupOpenDown = true;

0 commit comments

Comments
 (0)