Share via


CommandFactory.Create Method

Definition

Overloads

Create(Action)

Initializes Xamarin.Forms.Command

Create(Action<Object>)

Initializes Xamarin.Forms.Command

Create(Func<Task>)

Initializes a new instance of IAsyncCommand

Create(Action, Func<Boolean>)

Initializes Xamarin.Forms.Command

Create(Action<Object>, Func<Object,Boolean>)

Initializes Xamarin.Forms.Command

Create(Func<Task>, Func<Boolean>)

Initializes a new instance of IAsyncCommand

Create(Func<Task>, Func<Object,Boolean>)

Initializes a new instance of IAsyncCommand

Create(Func<Task>, Func<Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of IAsyncCommand

Create(Func<Task>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of IAsyncCommand

Create(Func<ValueTask>, Func<Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of AsyncValueCommand

Create(Func<ValueTask>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of AsyncValueCommand

Create<T>(Action<T>, Func<T,Boolean>)

Initializes Xamarin.Forms.CommandT

Create<T>(Action<T>)

Initializes Xamarin.Forms.CommandT

Create<TExecute,TCanExecute>(Func<TExecute,Task>, Func<TCanExecute,Boolean>)

Initializes a new instance of IAsyncCommand

Create<TExecute,TCanExecute>(Func<TExecute,Task>, Func<TCanExecute,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of IAsyncCommand

Create<TExecute,TCanExecute>(Func<TExecute,ValueTask>, Func<TCanExecute,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of AsyncValueCommand

Create<TExecute>(Func<TExecute,Task>)

Initializes a new instance of IAsyncCommand

Create<TExecute>(Func<TExecute,Task>, Func<Boolean>)

Initializes a new instance of IAsyncCommand

Create<TExecute>(Func<TExecute,Task>, Func<Object,Boolean>)

Initializes a new instance of IAsyncCommand

Create<TExecute>(Func<TExecute,Task>, Func<Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of IAsyncCommand

Create<TExecute>(Func<TExecute,Task>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of IAsyncCommand

Create<TExecute>(Func<TExecute,ValueTask>, Func<Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of AsyncValueCommand

Create<TExecute>(Func<TExecute,ValueTask>, Func<Object,Boolean>, Action<Exception>, Boolean, Boolean)

Initializes a new instance of AsyncValueCommand

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

Command<T>

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

Command<T>

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<TExecute>

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<TExecute>

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<TExecute>

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

IAsyncCommand<TExecute>

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

IAsyncCommand<TExecute>

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

IAsyncValueCommand<TExecute>

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

IAsyncValueCommand<TExecute>

IAsyncValueCommandTExecute

Applies to