# ScrollableControlExtensions

Namespace: **Wisej.Web.Markup**

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

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol) class.

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

```csharp
public class ScrollableControlExtensions
```

{% endtab %}

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

```visual-basic
Public Class ScrollableControlExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-e4f8ed47a52590951f725a10c269555e81d41d81%2Fstatic.png?alt=media) AutoScroll\<TControl>(control, autoScroll)

Sets the AutoScroll property for the specified [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol), enabling or disabling automatic scrolling.

| Parameter      | Type                                                                                                            | Description                                                                                                                              |
| -------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **TControl**   |                                                                                                                 | The type of the control, which must inherit from [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol). |
| **control**    | [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions) | The scrollable control for which to set the AutoScroll property.                                                                         |
| **autoScroll** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                                                 | A boolean value indicating whether to enable automatic scrolling. Default is `false`.                                                    |

**Returns:** [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions). The scrollable control with the updated AutoScroll property.

This method allows you to control whether the control automatically displays scroll bars when its contents exceed its visible boundaries.

```csharp

myScrollableControl.AutoScroll(true);

```

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-e4f8ed47a52590951f725a10c269555e81d41d81%2Fstatic.png?alt=media) AutoScrollMargin\<TControl>(control, autoScrollMargin)

Sets the AutoScrollMargin property of the specified [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol).

| Parameter            | Type                                                                                                            | Description                                                                                                                        |
| -------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **TControl**         |                                                                                                                 | The type of the control, must inherit from [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol). |
| **control**          | [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions) | The control for which to set the AutoScrollMargin property.                                                                        |
| **autoScrollMargin** | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size)                                               | A [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size) representing the scroll margin.                                |

**Returns:** [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions). The modified control with the updated AutoScrollMargin property.

This method allows you to specify the margin around the scrollable area of the control.

```csharp

myScrollableControl.AutoScrollMargin(new Size(10, 10));

```

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-e4f8ed47a52590951f725a10c269555e81d41d81%2Fstatic.png?alt=media) AutoScrollMinSize\<TControl>(control, autoScrollMinSize)

Sets the AutoScrollMinSize property of the specified [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol).

| Parameter             | Type                                                                                                            | Description                                                                                                                        |
| --------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **TControl**          |                                                                                                                 | The type of the control, must inherit from [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol). |
| **control**           | [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions) | The control for which to set the AutoScrollMinSize property.                                                                       |
| **autoScrollMinSize** | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size)                                               | A [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size) representing the minimum scrollable size.                      |

**Returns:** [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions). The modified control with the updated AutoScrollMinSize property.

This method allows you to specify the minimum size of the scrollable area of the control.

```csharp

myScrollableControl.AutoScrollMinSize(new Size(100, 100));

```

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-e4f8ed47a52590951f725a10c269555e81d41d81%2Fstatic.png?alt=media) OnScroll\<TControl>(control, action)

Attaches a scroll event handler to a [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol).

| Parameter    | Type                                                                                                            | Description                                                |
| ------------ | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| **TControl** |                                                                                                                 | The type of the scrollable control.                        |
| **control**  | [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions) | The control to which the scroll event handler is attached. |
| **action**   | [Action\<TControl, ScrollEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2)                     | The action to perform when the scroll event is triggered.  |

**Returns:** [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions). The control with the attached scroll event handler.

This method allows you to easily attach a scroll event handler to a scrollable control. The provided action is executed whenever the scroll event occurs.

```csharp

var myScrollableControl = new MyScrollableControl();
myScrollableControl.OnScroll((control, args) =>
{
// Handle scroll event
});

```

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-e4f8ed47a52590951f725a10c269555e81d41d81%2Fstatic.png?alt=media) ScrollBars\<TControl>(control, scrollBars)

Sets the ScrollBars property of the specified [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol).

| Parameter      | Type                                                                                                            | Description                                                                                                                        |
| -------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **TControl**   |                                                                                                                 | The type of the control, must inherit from [ScrollableControl](https://docs.wisej.com/api/wisej.web/containers/scrollablecontrol). |
| **control**    | [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions) | The control for which to set the ScrollBars property.                                                                              |
| **scrollBars** | [ScrollBars](https://docs.wisej.com/api/wisej.web/enumerations/wisej.web.scrollbars)                            | A [ScrollBars](#scrollbars``1) value indicating which scroll bars to display.                                                      |

**Returns:** [TControl](https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions). The modified control with the updated ScrollBars property.

This method allows you to specify which scroll bars are displayed for the control. This is assumed to be part of a custom implementation.

```csharp

myScrollableControl.ScrollBars(ScrollBars.Both);

```
