Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get Text value and fill ItemsSource when trying to implement MVVM #88

Open
lardecristo opened this issue Feb 7, 2021 · 0 comments

Comments

@lardecristo
Copy link

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant