Displays an Image

Image provides several features for working with images in fuse, we will go through them in some short examples.

Displaying an image from a file or an url:

<StackPanel>
    <Image File="some_file.png" />
    <Image Url="some_url" />
</StackPanel>

Displaying a multi-density image from files:

<StackPanel>
    <Image Files="logo.png, logo@2x.png, logo@4x.png" />
    <Image>
        <MultiDensityImageSource>
            <FileImageSource Density="1" File="logo.png" />
            <FileImageSource Density="2" File="logo@2x.png" />
            <FileImageSource Density="3" File="logo@4x.png" />
        </MultiDensityImageSource>
    </Image>
</StackPanel/>

Displaying a multi-density image from urls:

<StackPanel>
    <Image>
        <MultiDensityImageSource>
            <HttpImageSource Density="1" Url="..." />
            <HttpImageSource Density="2" Url="...@2x" />
            <HttpImageSource Density="3" Url="...@4x" />
        </MultiDensityImageSource>
    </Image>
</StackPanel>

Displaying an image from a file specified from JavaScript

Uno cannot automatically bundle images when their path is defined in JavaScript. Because of this, you have to manually bundle those by manually importing them in your unproj file. You can either bundle one file like this:

"Includes": [
    "*",
    "image.jpg:Bundle"
]

Or bundle an entire folder, or all files of a specific type, using wildcards:

"Includes": [
    "*.jpg:Bundle"
]

You can read more on bundling files with your project here..

When you have bundled your image files, you can refer to them from javascript like this:

<JavaScript>
    module.exports = {
        image: "image.jpg"
    };
</JavaScript>
<Image File="{image}" />

Location

Namespace
Fuse.Controls
Package
Fuse.Controls.Primitives 2.9.1
Show Uno properties and methods

Interface of Image

clearCache() js

Clear the image cache from disk. only applicable if image source is from Url

Color : float4 ux

Specifies a mask color used while drawing the image. This color is multiplied by the source color.

ContentAlignment : Alignment ux

Specifies the alignment of the image inside the element. This is used when the image itself does not fill, or overfills, the available space.

Density : float ux

Specifies the density of the image in relation to layout; the number of image pixels per logical point.

Load uno

Load the image from Url or Disk

MemoryPolicy : MemoryPolicy ux

Specifies a policy to control the loading and unloading of the image. The two common policies are PreloadRetain, the default which loads images at startup and keeps them loaded, and UnloadUnused which keeps only used images loaded.

Reload uno

Reload the image from Url or Disk

retry() js

Reload the image source if it is in a failed state.

Scale9Margin : float4 ux

For StretchMode="Scale9" this defines the four margin that split the image into 9-esctions for scaling.

StretchMode : StretchMode ux

Specifies how the size of the image element is calculated and how the image is stretched inside it.

Inherited from LayoutControl

Inherited from Control

Inherited from Element

ActualPosition : float2 uno

The position of the element, the position of its top-left corner to the top-left corner in the parent.

Anchor : Size2 ux

A point within the element to treat as its "epicenter".

Aspect : float ux

The aspect ratio that an element must fulfill in layout.

Offset : Size2 ux

Offets the position of the element after all other layout has been applied.

Inherited from Visual

bringIntoView() js

Requests that this visual be brought into the visible are of the screen. Typically a containing ScrollView will scroll to ensure it is visible.

Children : IList of Node ux

The children of the visual. All nodes placed inside the visual in UX markup are assigned to this list. The order of Visuals this list determines the order of layout. The Z-order of the children is by default equal to this order, but can be manipulated separately using methods like BringToFront and SendToBack.

InvalidateVisual uno

Indicates the visual for this node has changed. This allows the root-level node to know that it must draw, and any caching that it must invalidate the cache for this node.

InvalidateVisualComposition uno

Indicates the composition of the visual has changed, but that the visual drawing itself is still valid (for example a position change).

IsEnabled : bool ux

Whether this node is currently interactable. Disabled visuals do not receive input focus. However, they can still be visible and block hit test for underlaying objects.

IsLocalVisible : bool uno

Returns whether this visual is visible without concern for whether an ancestor visual is hidden or collapsed.

IsVisible : bool uno

Returns whether this visual is currently visible. Will return false if any of the ancestor visuals are hidden or collapsed. This property can not be used to check whether a visual is hidden because it is occluded by another visual, or is outside the view but otherwise visible.

Parameter : string ux

The parameter data for this visual, encoded as JSON, provided by a router if this visual represents a navigation page.

SnapToPixels : bool ux

Whether to snap the result of layout of this visual to physical device pixels.

ZOffset : float ux

Specifies a Z-Offset, visuals with higher values are in front of other visuals.

Inherited from Node

ContextParent : Node uno

The context parent is the semantic parent of this node. It is where non-UI structure should be resolved, like looking for the DataContext, a Navigation, or other semantic item.

FindNodeByName(Selector, Predicate<Node> (Node)) : Node uno

Finds the first node with a given name that satisfies the given acceptor. The serach algorithm works as follows: Nodes in the subtree are matched first, then it matches the nodes in the subtrees ofthe ancestor nodes by turn all the way to the root. If no matching node is found, the function returns null.

IsRootingStarted : bool uno

Whether rooting of this node has started. Note that even if this property returns true, rooting may not yet be completed for the node. See also IsRootingCompleted.

Name : Selector ux

Run-time name of the node. This property is automatically set using the ux:Name attribute.

OnRooted uno

If you override OnRooted you must call base.OnRooted() first in your derived class. No other processing should happen first, otherwise you might end up in an undefined state.

Inherited from PropertyObject

Inherited from object

Attached UX Attributes

Items (attached by Each) : object ux

The item collection that will be used to populate this visual.

MatchKey (attached by Each) : string ux

Shorthand for setting the MatchKey property on the implicit Each created when using the Items attached property.

Column (attached by Grid) : int ux

The index of the column the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.

Row (attached by Grid) : int ux

The index of the row the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.

GlobalKey (attached by Resource) : string ux

The ux:Global attribute creates a global resource that is accessible everywhere in UX markup.

Implemented Interfaces

IScriptObject uno

Interface for objects that can have a script engine representation