Hello @Eduardo Gomez , Welcome to Microsoft Q&A!
Use EventTriggerBehavior.Actions
and InvokeCommandAction
to handle event ItemInvoked,
then use x:Bind to link your ViewModel commands.
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="ItemInvoked">
<Core:EventTriggerBehavior.Actions>
<Core:InvokeCommandAction Command="{x:Bind viewModel.NavigateCommand}" />
</Core:EventTriggerBehavior.Actions>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
//using CommunityToolkit.Mvvm.ComponentModel;
//using CommunityToolkit.Mvvm.Input;
private ICommand _NavigateCommand;
public ICommand NavigateCommand => this._NavigateCommand ?? (this._NavigateCommand =
new RelayCommand<NavigationViewSelectionChangedEventArgs>(OnItemInvoked));
private void OnItemInvoked(NavigationViewSelectionChangedEventArgs args)
{
//NavigateTo your new page
NavigationService.NavigateTo(args.SelectedItem);
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.