I am using [RelayCommand] for handling the navigated event of WebView in .NET MAUI.
async void Navigated(WebNavigatedEventArgs args)
I have bound it in my XAML, using
<toolkit:EventToCommandBehavior
EventName="Navigated"
Command="{Binding NavigatedCommand}" />
The command is firing, the arguments are null. Am I missing something?
Edit: I want to clarify this a bit.
The command is called correctly, when the event is raised. The arguments in that command (WebNavigatedEventArgs args) are null.
If this is used as event in the page, there isn't any problem. The arguments hold the response and it is correct.
I am using CommunityToolkit.Maui Version 1.2.0. And CommunityToolkit.MVVM Version 8.0.0.
Edit2: After testing on another machine, the same code runs correctly and the arguments are passed to the command. (Dependency 6.0.400)
After updating it to 6.0.486 as well, the command parameters became null.
What does this mean? I have done a sample and it worked well.
The xaml:
The viewmodel:
Or you want to add a navigated event in the page.cs, you can try:
In the xaml:
In the page.cs:
In addition, I also tried use them together and found that the navigeted event will execute at first, then the command will execute after it.
Update how to pass the WebNavigatedEventArgs into the view model
In the view model:
In the page.cs:
In the xaml:
But I really don't suggest you do so.