Hi all, I have a user control [A], with a code behind method to invoke its viewmodel command :
void test() { if(this.BindingContext as AViewModel !=null) { var vm = this.BindingContext as AViewModel ; vm.ACommand.Execute(null); } }
However what should I do if I want to use this user control in other pages with different view model? I wonder is it correct to do the following?
void test() { if(this.BindingContext as AViewModel !=null) { var vm = this.BindingContext as AViewModel ; vm.ACommand.Execute(null); } **else if(this.BindingContext as BViewModel !=null) { var vm = this.BindingContext as BViewModel ; vm.BCommand.Execute(null); }** }
Thanks!