Rock Mobile Docs

Execute Command

Allows a command to be executed upon initialization (and repeated).

Inherits from Microsoft.Maui.Controls.ContentView

The ExecuteCommand control is a simple and flexible way to execute commands with customizable timing and repetition. It’s ideal for use cases like delayed actions or periodic updates.

Properties

PropertyTypeDescription
DelayintThe delay interval (in milliseconds) before the command executes.
RepeatboolIndicates if the command should repeat. Repeat indefinitely if RepeatCount is not specified.
RepeatCountintThe number of times the command repeats. Use -1 for unlimited.
StartWithExecutionboolIf true, the command executes immediately before starting the delay timer.
CommandICommandThe command to execute.
CommandParameterobjectA parameter passed to the command when executed.

Example

In this example we used in an app to welcome people with a periodic toast message like, "Welcome to Rock Solid Church!!".

<Rock:ExecuteCommand
    Command="{Binding ShowToast}"
    CommandParameter="Welcome to Rock Solid Church!!"
    Delay="3000"
    Repeat="true" />
  • Command: Bound to the ShowToast command, which handles the logic for displaying the message.
  • CommandParameter: Passes the string "Welcome to Rock Solid Church!!" as a parameter to the command.
  • Delay: Specifies a 3-second delay (3000 ms) before executing the command.
  • Repeat: Ensures the command executes repeatedly (Repeat indefinitely if the RepeatCount is not specified).