CommandFactory.Create Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Create(Action)
Initializes Xamarin.Forms.Command
public static Xamarin.Forms.Command Create(Action execute);
Parameters
- execute
- System.Action
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
Returns
Xamarin.Forms.Command
Applies to
Create(Action<Object>)
Initializes Xamarin.Forms.Command
public static Xamarin.Forms.Command Create(Action<object> execute);
Parameters
- execute
- System.Action<System.Object>
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
Returns
Xamarin.Forms.Command
Applies to
Create(Func<Task>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand Create(Func<System.Threading.Tasks.Task> execute);
Parameters
- execute
- System.Func<System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
Returns
IAsyncCommand
Applies to
Create(Action, Func<Boolean>)
Initializes Xamarin.Forms.Command
public static Xamarin.Forms.Command Create(Action execute, Func<bool> canExecute);
Parameters
- execute
- System.Action
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
Returns
Xamarin.Forms.Command
Applies to
Create(Action<Object>, Func<Object,Boolean>)
Initializes Xamarin.Forms.Command
public static Xamarin.Forms.Command Create(Action<object> execute, Func<object,bool> canExecute);
Parameters
- execute
- System.Action<System.Object>
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
Returns
Xamarin.Forms.Command
Applies to
Create(Func<Task>, Func<Boolean>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand Create(Func<System.Threading.Tasks.Task> execute, Func<bool> canExecute);
Parameters
- execute
- System.Func<System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
Returns
IAsyncCommand
Applies to
Create(Func<Task>, Func<Object,Boolean>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand Create(Func<System.Threading.Tasks.Task> execute, Func<object,bool>? canExecute);
Parameters
- execute
- System.Func<System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
Returns
IAsyncCommand
Applies to
Create(Func<Task>, Func<Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand Create(Func<System.Threading.Tasks.Task> execute, Func<bool> canExecute, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Parameters
- execute
- System.Func<System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncCommand
Applies to
Create(Func<Task>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand Create(Func<System.Threading.Tasks.Task> execute, Func<object,bool>? canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Parameters
- execute
- System.Func<System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncCommand
Applies to
Create(Func<ValueTask>, Func<Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of AsyncValueCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncValueCommand Create(Func<System.Threading.Tasks.ValueTask> execute, Func<bool> canExecute, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Parameters
- execute
- System.Func<System.Threading.Tasks.ValueTask>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncValueCommand
Applies to
Create(Func<ValueTask>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of AsyncValueCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncValueCommand Create(Func<System.Threading.Tasks.ValueTask> execute, Func<object,bool>? canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Parameters
- execute
- System.Func<System.Threading.Tasks.ValueTask>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncValueCommand
Applies to
Create<T>(Action<T>, Func<T,Boolean>)
Initializes Xamarin.Forms.CommandT
public static Xamarin.Forms.Command<T> Create<T>(Action<T> execute, Func<T,bool> canExecute);
Type Parameters
- T
Parameters
- execute
- System.Action<T>
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<T,System.Boolean>
Returns
Xamarin.Forms.CommandT
Applies to
Create<T>(Action<T>)
Initializes Xamarin.Forms.CommandT
public static Xamarin.Forms.Command<T> Create<T>(Action<T> execute);
Type Parameters
- T
Parameters
- execute
- System.Action<T>
The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false
Returns
Xamarin.Forms.CommandT
Applies to
Create<TExecute,TCanExecute>(Func<TExecute,Task>, Func<TCanExecute,Boolean>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute,TCanExecute>? Create<TExecute,TCanExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<TCanExecute,bool>? canExecute);
Type Parameters
- TExecute
- TCanExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<TCanExecute,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
Returns
IAsyncCommand
Applies to
Create<TExecute,TCanExecute>(Func<TExecute,Task>, Func<TCanExecute,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute,TCanExecute>? Create<TExecute,TCanExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<TCanExecute,bool> canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
- TCanExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<TCanExecute,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncCommand
Applies to
Create<TExecute,TCanExecute>(Func<TExecute,ValueTask>, Func<TCanExecute,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of AsyncValueCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncValueCommand<TExecute,TCanExecute>? Create<TExecute,TCanExecute>(Func<TExecute,System.Threading.Tasks.ValueTask>? execute, Func<TCanExecute,bool> canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
- TCanExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.ValueTask>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<TCanExecute,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncValueCommand>
Applies to
Create<TExecute>(Func<TExecute,Task>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute> Create<TExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
Returns
IAsyncCommand
Applies to
Create<TExecute>(Func<TExecute,Task>, Func<Boolean>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute> Create<TExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<bool> canExecute);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
Returns
IAsyncCommand
Applies to
Create<TExecute>(Func<TExecute,Task>, Func<Object,Boolean>)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute> Create<TExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<object,bool>? canExecute);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
Returns
IAsyncCommand
Applies to
Create<TExecute>(Func<TExecute,Task>, Func<Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute> Create<TExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<bool> canExecute, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncCommandTExecute
Applies to
Create<TExecute>(Func<TExecute,Task>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of IAsyncCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncCommand<TExecute>? Create<TExecute>(Func<TExecute,System.Threading.Tasks.Task>? execute, Func<object,bool> canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.Task>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncCommandTExecute
Applies to
Create<TExecute>(Func<TExecute,ValueTask>, Func<Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of AsyncValueCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncValueCommand<TExecute> Create<TExecute>(Func<TExecute,System.Threading.Tasks.ValueTask>? execute, Func<bool> canExecute, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.ValueTask>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncValueCommandTExecute
Applies to
Create<TExecute>(Func<TExecute,ValueTask>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)
Initializes a new instance of AsyncValueCommand
public static Xamarin.CommunityToolkit.ObjectModel.IAsyncValueCommand<TExecute>? Create<TExecute>(Func<TExecute,System.Threading.Tasks.ValueTask>? execute, Func<object,bool> canExecute = default, Action<Exception>? onException = default, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true);
Type Parameters
- TExecute
Parameters
- execute
- System.Func<TExecute,System.Threading.Tasks.ValueTask>
The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false
- canExecute
- System.Func<System.Object,System.Boolean>
The Function that verifies whether or not AsyncCommand should execute.
- onException
- System.Action<System.Exception>
If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
- continueOnCapturedContext
- System.Boolean
If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- allowsMultipleExecutions
- System.Boolean
Returns
IAsyncValueCommandTExecute