# 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](/api/wisej.web/containers/scrollablecontrol.md) class.

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

```csharp
public class ScrollableControlExtensions
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) AutoScroll\<TControl>(control, autoScroll)

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

| Parameter      | Type                                                                                         | Description                                                                                                           |
| -------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **TControl**   |                                                                                              | The type of the control, which must inherit from [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md). |
| **control**    | [TControl](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md). 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);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) AutoScrollMargin\<TControl>(control, autoScrollMargin)

Sets the AutoScrollMargin property of the specified [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md).

| Parameter            | Type                                                                                         | Description                                                                                                     |
| -------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| **TControl**         |                                                                                              | The type of the control, must inherit from [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md). |
| **control**          | [TControl](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md). 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));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) AutoScrollMinSize\<TControl>(control, autoScrollMinSize)

Sets the AutoScrollMinSize property of the specified [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md).

| Parameter             | Type                                                                                         | Description                                                                                                     |
| --------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| **TControl**          |                                                                                              | The type of the control, must inherit from [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md). |
| **control**           | [TControl](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md). 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));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnScroll\<TControl>(control, action)

Attaches a scroll event handler to a [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md).

| Parameter    | Type                                                                                         | Description                                                |
| ------------ | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| **TControl** |                                                                                              | The type of the scrollable control.                        |
| **control**  | [TControl](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md). 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
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) ScrollBars\<TControl>(control, scrollBars)

Sets the ScrollBars property of the specified [ScrollableControl](/api/wisej.web/containers/scrollablecontrol.md).

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

**Returns:** [TControl](/api/wisej.web.markup/extensions/wisej.web.markup.scrollablecontrolextensions.md). 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);

```


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
