dotMorten / MauiEx

A set of .NET MAUI controls
Apache License 2.0
225 stars 55 forks source link

How it worked with MVVM? #56

Closed scriptBoris closed 4 years ago

scriptBoris commented 5 years ago

How it worked with MVVM?

dotMorten commented 5 years ago

Could you please be more specific?

scriptBoris commented 5 years ago

I want use binding Commands

dotMorten commented 5 years ago

More specific as in multiple descriptive sentences, and example code that demonstrates what doesn't work and what you want to achieve.

ta-yamaoka commented 5 years ago

@scriptBoris

I want use binding Commands

Use EventToCommandBehavior.

dotMorten commented 4 years ago

Close due to lack of feedback. Feel free to provide more detailed information and reopen.

Kapusch commented 4 years ago

Hi @dotMorten ,

First, thank you for this very nice auto complete component !

To explain a bit more the origin of this topic, I would say it was about "How to trigger a Command (located in the binded ViewModel) from your component in the XAML View ?".

Well actually, I wondered it too, and I've followed the recommendation of @ta-yamaoka .

Hence, if you still want to do that @scriptBoris , please check the snippet below :

`

    <autoComplete:AutoSuggestBox
        ItemsSource="{Binding SuggestedItems}"
        PlaceholderText="Write some text"
        Text="{Binding SelectedItem, Mode=TwoWay}">

        <autoComplete:AutoSuggestBox.Behaviors>
            <behaviors:EventToCommandBehavior
                Command="{Binding AutoCompleteTextChanged}"
                CommandParameter="AutoSuggestBoxTextChangedEventArgs"
                EventName="TextChanged" />
            <!--<behaviors:EventToCommandBehavior
                Command="AutoCompleteSuggestionChosen"
                CommandParameter="AutoSuggestBoxSuggestionChosenEventArgs"
                EventName="SuggestionChosen" />-->
            <behaviors:EventToCommandBehavior
                Command="{Binding AutoCompleteQuerySubmitted}"
                CommandParameter="AutoSuggestBoxQuerySubmittedEventArgs"
                EventName="QuerySubmitted" />
        </autoComplete:AutoSuggestBox.Behaviors>

    </autoComplete:AutoSuggestBox>`