> For the complete documentation index, see [llms.txt](https://docs.wisej.com/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md).

# ICommandSourceExtensions

Namespace: **Wisej.Web.Markup**

Assembly: **Wisej.Framework** (4.1.0.0)

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [ICommandSource](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommandsource.md) interface.

{% tabs %}
{% tab title="C#" %}

```csharp
public class ICommandSourceExtensions
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class ICommandSourceExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/kO1NJonWXUyy0yRrTxGp) Command\<TCommandSource>(button, value)

Sets the Command property of the specified [ICommandSource](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommandsource.md).

| Parameter          | Type                                                                                            | Description                                                                                                                                   |
| ------------------ | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **TCommandSource** |                                                                                                 | The type of the command source, must implement [ICommandSource](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommandsource.md). |
| **button**         | [TCommandSource](/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md) | The command source for which to set the Command property.                                                                                     |
| **value**          | [ICommand](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommand.md)               | The [ICommand](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommand.md) to associate with the command source.                   |

**Returns:** [TCommandSource](/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md). The modified command source with the updated Command property.

This method allows you to associate a command with the command source, enabling command-based interactions.

```csharp

myCommandSource.Command(new RelayCommand());

```

### ![](/files/kO1NJonWXUyy0yRrTxGp) OnCommandChanged\<TCommandSource>(button, action)

Attaches an event handler for the CommandChanged event of the specified [ICommandSource](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommandsource.md).

| Parameter          | Type                                                                                            | Description                                                                                                                                   |
| ------------------ | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **TCommandSource** |                                                                                                 | The type of the command source, must implement [ICommandSource](https://docs.wisej.com/api/wisej.web/interfaces/wisej.web.icommandsource.md). |
| **button**         | [TCommandSource](/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md) | The command source to attach the event handler to.                                                                                            |
| **action**         | [Action\<TCommandSource>](https://docs.microsoft.com/dotnet/api/system.action-1)                | An action to execute when the command changes.                                                                                                |

**Returns:** [TCommandSource](/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md). The modified command source with the attached CommandChanged event handler.

This method allows you to execute a custom action whenever the command associated with the command source changes.

```csharp

myCommandSource.OnCommandChanged(cs =>
{
AlertBox.Show("Command changed!");
});

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.icommandsourceextensions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
