If you change the private constructors of the DelegateCommand
class to public you will see that
will show the following error message when the constructor is invoked inside the
“ The call is ambiguous between the following methods or properties: 'Microsoft.Practices.Prism.StoreApps.DelegateCommand.DelegateCommand(System.Action)' and 'Microsoft.Practices.Prism.StoreApps.DelegateCommand.DelegateCommand(System.Func<System.Threading.Tasks.Task>)'
Based on my understanding, this ambiguity appears because the compiler cannot determine if you want to pass the method as a
delegate or an Action
delegate due to how the method groups are converted to compatible delegate types. This is explained in deep by
in the following links:
When the constructors that accept a Func
are declared as private the compiler determines that you are invoking the
constructor "versions" from outside the class, as they are the only accessible constructors in that scope. In order to access the
constructor "versions" of the DelegateCommand
, the class defines the static methods which avoid the ambiguity by passing an explicit
or Func<T, Task>
to the corresponding constructors, allowing you to call them.
I hope you find this useful,