# PictureBoxExtensions

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 [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md) class.

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

```csharp
public class PictureBoxExtensions
```

{% endtab %}

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

```visual-basic
Public Class PictureBoxExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) BorderStyle\<TPictureBox>(pictureBox, borderStyle)

Sets the BorderStyle property of the specified [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md).

| Parameter       | Type                                                                                     | Description                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| **TPictureBox** |                                                                                          | The type of the picture box, must inherit from [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md). |
| **pictureBox**  | [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md) | The picture box for which to set the BorderStyle property.                                                   |
| **borderStyle** | [BorderStyle](/api/wisej.web/enumerations/wisej.web.borderstyle.md)                      | The [BorderStyle](#borderstyle``1) to set for the picture box.                                               |

**Returns:** [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md). The modified picture box with the updated BorderStyle property.

This method allows you to specify the border style for the picture box.

```csharp

myPictureBox.BorderStyle(BorderStyle.FixedSingle);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnLoadCompleted\<TPictureBox>(pictureBox, action)

Attaches an event handler for the LoadCompleted event of the specified [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md).

| Parameter       | Type                                                                                     | Description                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| **TPictureBox** |                                                                                          | The type of the picture box, must inherit from [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md). |
| **pictureBox**  | [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md) | The picture box to attach the event handler to.                                                              |
| **action**      | [Action\<TPictureBox>](https://docs.microsoft.com/dotnet/api/system.action-1)            | An action to execute when the image load is completed.                                                       |

**Returns:** [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md). The modified picture box with the attached LoadCompleted event handler.

This method allows you to execute a custom action whenever the image loading process of the picture box is completed.

```csharp

myPictureBox.OnLoadCompleted(pb =>
{
AlertBox.Show("Image load completed!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnSizeModeChanged\<TPictureBox>(pictureBox, action)

Attaches an event handler for the SizeModeChanged event of the specified [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md).

| Parameter       | Type                                                                                     | Description                                                                                                  |
| --------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| **TPictureBox** |                                                                                          | The type of the picture box, must inherit from [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md). |
| **pictureBox**  | [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md) | The picture box to attach the event handler to.                                                              |
| **action**      | [Action\<TPictureBox>](https://docs.microsoft.com/dotnet/api/system.action-1)            | An action to execute when the size mode changes.                                                             |

**Returns:** [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md). The modified picture box with the attached SizeModeChanged event handler.

This method allows you to execute a custom action whenever the size mode of the picture box changes.

```csharp

myPictureBox.OnSizeModeChanged(pb =>
{
AlertBox.Show("Size mode changed!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) SizeMode\<TPictureBox>(pictureBox, sizeMode)

Sets the SizeMode property of the specified [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md).

| Parameter       | Type                                                                                     | Description                                                                                                       |
| --------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| **TPictureBox** |                                                                                          | The type of the picture box, must inherit from [PictureBox](/api/wisej.web/content/wisej.web.picturebox.md).      |
| **pictureBox**  | [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md) | The picture box for which to set the SizeMode property.                                                           |
| **sizeMode**    | [PictureBoxSizeMode](/api/wisej.web/enumerations/wisej.web.pictureboxsizemode.md)        | The [PictureBoxSizeMode](/api/wisej.web/enumerations/wisej.web.pictureboxsizemode.md) to set for the picture box. |

**Returns:** [TPictureBox](/api/wisej.web.markup/extensions/wisej.web.markup.pictureboxextensions.md). The modified picture box with the updated SizeMode property.

This method allows you to specify the size mode for the picture box, which determines how the image is displayed.

```csharp

myPictureBox.SizeMode(PictureBoxSizeMode.StretchImage);

```


---

# 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.pictureboxextensions.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.
