I try get Text value in my MVVM. I think I have this problem, because I don't get the object AutoSuggestBox when I use Behaviors. I receive this AutoSuggestBoxTextChangedEventArgs object , but not AutoSuggestBox object.
AutoSuggestBox box = (AutoSuggestBox)sender;
// Only get results when it was a user typing,
// otherwise assume the value got filled in by TextMemberPath
// or the handler for SuggestionChosen.
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{
if (string.IsNullOrWhiteSpace(box.Text) || box.Text.Length < 3)
box.ItemsSource = null;
else
{
var suggestions = await GetSuggestions(box.Text);
box.ItemsSource = suggestions.ToList();
}
}
}`
I try get Text value in my MVVM. I think I have this problem, because I don't get the object AutoSuggestBox when I use Behaviors. I receive this AutoSuggestBoxTextChangedEventArgs object , but not AutoSuggestBox object.
In your example, you use code-behind.
Your example
`private async void dynamicSuggestBox_TextChanged(object sender, dotMorten.Xamarin.Forms.AutoSuggestBoxTextChangedEventArgs args) {
AutoSuggestBox box = (AutoSuggestBox)sender; // Only get results when it was a user typing, // otherwise assume the value got filled in by TextMemberPath // or the handler for SuggestionChosen. if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { if (string.IsNullOrWhiteSpace(box.Text) || box.Text.Length < 3) box.ItemsSource = null; else { var suggestions = await GetSuggestions(box.Text); box.ItemsSource = suggestions.ToList(); } } }`
I like the same code, but in MVVM pattern.
"I still learning English."