Tools: I am using Xamarin.form MVVM.
Question: How do I set up basic AsyncCommand command with Task?
Debug: I am not getting any error, when I click on button, Displaybox alert doesnt show up. I check and addcommand method is not getting runned on tap.
Bind: I also have bind View with ViewModel
BindingContext = new ProductViewModel(); I watched a tutorial by microsoft and there seem to be working just fine. Did I missed something?
View Page
<Button Text="Add" Command="{Binding AddCommand}" /> ViewModel Page
public class ProductViewModel : INotifyPropertyChanged { ... public AsyncCommand AddComamnd { get; } public ProductViewModel() { ... AddComamnd = new AsyncCommand(OnAddComamnd); } public async Task OnAddComamnd() { await App.Current.MainPage.DisplayAlert("Alert", "You have been alerted", "OK"); // I have also tried both (App and Application) neither works } } https://stackoverflow.com/questions/67427689/how-to-set-up-basic-asynccommand-with-task-in-xamarin-form May 07, 2021 at 08:55AM
没有评论:
发表评论