Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to implement the TextChanged the CommunityToolkit MVVM way

I am using the .Net Maui’s community toolkit and have some mvvm binding going on in a project.

I have a collectionview and a Searchbar connected to a ViewModel. I wish to implement the Searchbar’s is TextChanged, but with no luck.

it is saying,

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Event "Textchanged" can only be bound to properties of delegate type ‘EventHandler’1’

I saw this Solution here on stack overflow, I however am using the COmmunityToolkit.

Below are the XAML and ViewModel

XAML Page

The Viewmodel

>Solution :

You can use EventToCommandBehavior of CommunityToolkit to bind Command:

<SearchBar ....>
   <SearchBar.Behaviors>
       <toolkit:EventToCommandBehavior
                EventName="TextChanged"
                Command="{Binding TextChangedCommand}" />
   </SearchBar.Behaviors>
</SearchBar>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading