I wonder that is it a good practice to bind an event to an async Task method by using x:bind?
Basically, I'm using MVVM, which my ViewModel contains some async Task method, and I want to x:bind the async Task method to an event in my view (which is actually works fine), however, I hear that we shouldn't make an event into an async Task.
Here's some code example:
Event x:bind to async Task method
SomeViewModel.cs
public class SomeViewModel
{
public async Task DoneAsync()
{
//...some code
}
}
SomeView.xaml
<button context="click" click="{x:bind DoneAsync}"/>
Curently what I did is to use async Task in code behind instead, for safety.
SomeView.xaml
<button context="click" click="Done_clicked"/>
SomeView.cs
public async void Done_clicked(...)
{
await vm.DoneAsync();
}