Displays static and animated images from various sources including embedded resources, files, and URLs. Supports automatic GIF animation playback, SVG rendering, and aspect ratio control.
Basic Usage
// Embedded resourcenewImage().SetImageSource("logo.png")// Local filenewImage().SetImageSource("file:/images/photo.jpg")// Web imagenewImage().SetImageSource("https://example.com/image.png")// With aspect rationewImage().SetImageSource("photo.jpg").SetAspect(Aspect.AspectFill).SetDesiredSize(newSize(200,200))
Image Sources
Images can be loaded from different sources using prefixes:
Prefix
Description
Example
(none)
Embedded resource in any loaded assembly
"logo.png"
file:
Local file path
"file:/path/to/image.png"
http:// or https://
Web image (loaded asynchronously)
"https://example.com/image.png"
Image-Specific Methods
Method
Description
SetImageSource(string)
Sets the image source path/URL
BindImageSource(name, getter)
Binds image source
SetAspect(Aspect)
Sets scaling mode (default: Fill)
BindAspect(name, getter)
Binds aspect
SetTintColor(Color)
Sets tint color for SVG images
BindTintColor(name, getter)
Binds tint color
Aspect Values
Value
Description
Aspect.Fill
Stretches to fill space, may distort
Aspect.AspectFit
Scales to fit within space, preserves ratio, may leave empty space
Aspect.AspectFill
Scales to fill space, preserves ratio, may crop
Supported Formats
Static Images: PNG, JPEG, WebP, BMP, ICO
Animated Images: GIF (automatic playback)
Vector Graphics: SVG (rendered at display size for crisp scaling)
GIF animations play automatically when loaded. SVG images are rendered at the element’s size for optimal quality at any scale.
Layout Methods
Methods inherited from UiElement:
Method
Description
SetMargin(Margin)
Sets outer margin
BindMargin(name, getter)
Binds margin
SetHorizontalAlignment(HorizontalAlignment)
Sets horizontal alignment
BindHorizontalAlignment(name, getter)
Binds horizontal alignment
SetVerticalAlignment(VerticalAlignment)
Sets vertical alignment
BindVerticalAlignment(name, getter)
Binds vertical alignment
SetDesiredSize(Size)
Sets explicit size
BindDesiredSize(name, getter)
Binds size
SetDesiredWidth(float)
Sets explicit width
BindDesiredWidth(name, getter)
Binds width
SetDesiredHeight(float)
Sets explicit height
BindDesiredHeight(name, getter)
Binds height
HorizontalAlignment Values
Value
Description
HorizontalAlignment.Undefined
Default behavior
HorizontalAlignment.Left
Align to left
HorizontalAlignment.Center
Center horizontally
HorizontalAlignment.Right
Align to right
HorizontalAlignment.Stretch
Stretch to fill width
VerticalAlignment Values
Value
Description
VerticalAlignment.Undefined
Default behavior
VerticalAlignment.Top
Align to top
VerticalAlignment.Center
Center vertically
VerticalAlignment.Bottom
Align to bottom
VerticalAlignment.Stretch
Stretch to fill height
Appearance Methods
Methods inherited from UiElement:
Method
Description
SetIsVisible(bool)
Shows/hides element
BindIsVisible(name, getter)
Binds visibility
SetOpacity(float)
Sets opacity 0.0-1.0 (default: 1.0)
BindOpacity(name, getter)
Binds opacity
SetBackground(IBackground)
Sets background (gradient, solid, etc.)
SetBackground(Color)
Sets solid color background
BindBackground(name, getter)
Binds background
SetCornerRadius(float)
Sets corner radius
BindCornerRadius(name, getter)
Binds corner radius
SetVisualOffset(Point)
Offsets visual position
BindVisualOffset(name, getter)
Binds visual offset
Shadow Methods
Methods inherited from UiElement:
Method
Description
SetShadowColor(Color)
Sets shadow color
BindShadowColor(name, getter)
Binds shadow color
SetShadowOffset(Point)
Sets shadow offset
BindShadowOffset(name, getter)
Binds shadow offset
SetShadowBlur(float)
Sets shadow blur radius
BindShadowBlur(name, getter)
Binds shadow blur
SetShadowSpread(float)
Sets shadow spread
BindShadowSpread(name, getter)
Binds shadow spread
Focus Methods
Methods inherited from UiElement:
Method
Description
SetTabIndex(int?)
Sets tab order (null = auto)
BindTabIndex(name, getter)
Binds tab index
SetTabStop(bool)
Include in tab navigation (default: true)
BindTabStop(name, getter)
Binds tab stop
SetFocusRingColor(Color)
Sets focus ring color
SetFocusRingWidth(float)
Sets focus ring stroke width
SetFocusRingOffset(float)
Sets focus ring offset from bounds
SetFocusedBackground(IBackground)
Sets background when focused
SetFocusedBackground(Color)
Sets solid background when focused
SetFocusedBorderColor(Color?)
Sets border color when focused
Image is not focusable by default (IsFocusable = false).
Accessibility Methods
Methods inherited from UiElement:
Method
Description
SetAccessibilityLabel(string?)
Sets screen reader label
BindAccessibilityLabel(name, getter)
Binds accessibility label
SetAccessibilityHint(string?)
Sets additional context hint
BindAccessibilityHint(name, getter)
Binds accessibility hint
SetAccessibilityValue(string?)
Sets current value description
BindAccessibilityValue(name, getter)
Binds accessibility value
SetAccessibilityTraits(AccessibilityTrait)
Sets accessibility traits
BindAccessibilityTraits(name, getter)
Binds accessibility traits
AddAccessibilityTraits(AccessibilityTrait)
Adds traits to existing
RemoveAccessibilityTraits(AccessibilityTrait)
Removes specific traits
SetIsAccessibilityElement(bool)
Include in accessibility tree
SetHighContrastBackground(IBackground)
Background for high contrast mode
SetHighContrastBackground(Color)
Solid background for high contrast
SetHighContrastForeground(Color)
Text color for high contrast mode
SetEnforceMinimumTouchTarget(bool)
Enforce 44x44 minimum size
Image has AccessibilityRole.Image by default. Always set an accessibility label for decorative images or images conveying information.