question

BrentEsh-0336 avatar image
0 Votes"
BrentEsh-0336 asked NicoZhu-MSFT commented

AutoSuggestBox scrolling

The AutoSuggestBox suggestions list seems really inconsistent with its scrolling, especially when it appears above the AutoSuggestBox.

I found that when the items source collection changes, the listview usually scrolls to the top rather than to the first item (the first item is at the bottom when the popup is above the AutoSuggestBox). I also noticed that sometimes when the popup is below the AutoSuggestBox it will sometimes show the first item scrolled out of view. And other times it will scroll randomly to the center of the list.

I dealt with it using this ugly code but I'd rather use a more standard implementation:

                 *if (AssociatedObject?.IsSuggestionListOpen == true && Popup != null && Popup.HorizontalOffset == 0)//still open, opening above or below
                 {
                     var border = (Border)Popup.Child;
                     var listView = (ListView)border.Child;
                     if (listView.ItemsSource != null && VisualTreeHelper.GetChildrenCount(border.Child) > 0)
                     {
                         var scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(listView, 0), 0);
                         var scrollLocation = Popup.VerticalOffset < 0 ? scrollViewer.ScrollableHeight : 0;
                         scrollViewer.ChangeView(null, scrollLocation, null, disableAnimation: true);
                     }
                 }*
windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please use ScrollIntoView method to scroll to first item of suggest list when the listview display


0 Votes 0 ·

0 Answers