Image Viewer
A thumbnail that opens the image over the page, with zoom controls.
Installation
bash
shellui-native add image-viewer
Platforms: MAUI · Avalonia. Also installs icon.
Usage
Basic
<ui:ImageViewer Source="harbour.jpg" Description="The harbour at dusk"
WidthRequest="256" HeightRequest="160" /><ui:ImageViewer Source="/Assets/harbour.jpg" Description="The harbour at dusk"
Width="256" Height="160" />Not available on yet
Give the viewer a size: the thumbnail fills it. A tap opens the image over the page on a dark backdrop, with zoom out, reset, zoom in and close controls. A tap on the backdrop or Escape closes it.
A smaller thumbnail file
Set ThumbnailSource to a smaller file for the page. Source then loads only when the viewer opens.
Zoom
Zoom goes from 0.5 to 4, where 1 fits the page. Zooming scales the image around its centre; it doesn't pan. ZoomIn(), ZoomOut() and ResetZoom() do what the controls do.
MAUI and Avalonia
Sourceis anImageSourceon MAUI (an image inResources/Images) and anIImageon Avalonia (a resource path such as/Assets/photo.jpg).- How the thumbnail fills its box is
Aspecton MAUI andStretchon Avalonia. - MAUI zooms with a pinch. Avalonia zooms with the mouse wheel and the + / - / 0 keys.
- On Avalonia the thumbnail and the controls are tab stops.
API
XAML children go to Items on Avalonia.
| Property | Type | Default | Description |
|---|---|---|---|
Source |
ImageSource (MAUI) · IImage? (Avalonia) |
null |
The image shown in the viewer, and as the thumbnail when ThumbnailSource isn't set. |
ThumbnailSource |
ImageSource (MAUI) · IImage? (Avalonia) |
null |
A smaller file for the page; Source then loads only in the viewer. |
Description |
string |
— | What the image shows, for screen readers. |
Aspect |
Aspect |
AspectFill |
How the thumbnail fills its box. MAUI only. |
Open |
bool |
false |
Whether the viewer is open. Two-way bindable. |
Stretch |
Stretch |
UniformToFill |
How the thumbnail fills its box. Avalonia only. |
| Event | Arguments | Description |
|---|---|---|
OpenChanged |
bool |
Opened or closed. |
| Method | Description |
|---|---|
ZoomIn() |
Zooms in one step, up to 4. |
ZoomOut() |
Zooms out one step, down to 0.5. |
ResetZoom() |
Back to 1, where the image fits the page. |
SetOpen(bool value) |
Opens or closes it. |