How to use SelectedIndexChanged or CommandParameter with CommunityToolkit.Mvvm

Bhuwan 736 Reputation points
2025-01-18T16:28:39.4233333+00:00

I am using CommunityToolkit.Mvvm with ObservableObject and ObservableProperty. In the MVVM pattern, how can I trigger the SelectedIndexChanged event for a Picker when an item is selected, or handle changes in an Entry when typing into the textbox?

[RelayCommand]

private void OnChanged()

{

}

<Picker TitleColor="{StaticResource LabelPlaceHolder}"

ItemsSource="{Binding Countrys}"

ItemDisplayBinding="{Binding Name}"

SelectedItem="{Binding SelectedItemCountry,Mode=TwoWay}"
SelectedIndexChanged="{Binding OnChanged}"

FontFamily="OpenSansSemibold"

FontSize="12">

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,834 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.