Open mdmozibur opened 5 years ago
I am thinking of an ugly work around, which involves checking the args.Reason
in the TextChanged
event handler. I hope this critical bug will be addressed as soon as possible.
The information in the docs indicate you should be checking the args.Reason
. Follow that guideline and reactivate if you're still having problems.
@chrisglein I have checked, still happens. Using the following code:
private void SearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if (args.Reason != AutoSuggestionBoxTextChangeReason.UserInput)
return;
CVS.Source = GlobalShortcuts.ToList();
}
This is the result:
Please re-open the issue. This is a bug!
I figured that if set the UpdateTextOnSelect
property to false then this becomes somewhat manageable, but still.. the SuggestionChosen
event fires without me selecting anything.
@MuziburRahman Sorry, my mistake for misreading that. I thought you were adverse to checking Reason
. We'll take a look.
Just to set expectations. AutoSuggestBox's control code isn't in WinUI so this likely needs WinUI3 to fix unless it's a bug in the control style (which we can patch with WinUI2)
I just noticed that it still happens with WinUI 3. But in my case, only the first time when items get bound to the control, the first item in the suggestion list gets selected. After that it works as one would expect.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Still an issue...
If not bound to a
CollectionViewSource
, it works. But when it'sItemsSource
is bound to aCollectionViewSource
, on theTextChanged
event, it automatically chooses the first of the suggestions, thus, changing the text once again.Steps to reproduce the bug
Change the MainPage.xaml to this:
and the MainPage.xaml.cs to this:
AutoSuggestBox
. Notice that the 1st suggestion is chosen automatically.Screenshots
Version Info
I produced this with the
AutoSuggestBox
from Windows.UI.Xaml.Control , but I think this also happens to the one of Microsoft.UI.Xaml.ControlEdit: Checking for
args.Reason
doesn't prevent this to happen: