You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using an image requires the Image module to be loaded.
10
+
11
+
The purpose of this article is to show the basic functionality of the Image view. The snippets demonstrates some scenarios and the usage of the ImageView specifics properties
The example demonstrates how we could load an image, which is available in the App_Resources. More about adding an image in `App_Resources` folder could be found [here]({% slug images %}).
### Creating an image and setting its src to Data URI
86
+
The Image source could be load also from a local file. The path to the image should start with a tilde(`~`) as it is shown in the example above. Using `~/` prefix, we can load images relative to the project `app` folder
87
+
88
+
### Loading an image from Data URI
89
+
37
90
{%snippet img-create-datauri%}
38
91
92
+
In the sample code is shown, how to load an image source data, while using data URI.
93
+
39
94
### Setting image stretching
95
+
96
+
The stretch functionality allows us to describe how content is resized to fill its allocated space.
97
+
The available options for this property are as follow:
98
+
99
+
*`none` - the image preserves its original size
100
+
*`fill` - the image is resized to fill the destination dimensions. In this case, the aspect ratio is not preserved.
101
+
*`aspectFit` - the image is resized to fit the destination dimensions while it preserves its native aspect ratio. If the aspect ratio of the destination rectangle differs from the image, the image will be clipped to fit in the destination.
102
+
*`aspectFill` - the image is resized to fill in the destination dimensions while it preserves its native aspect ratio.
103
+
104
+
The default value for this property is `aspectFit`.
105
+
106
+
Setting up the stretch property could be done via the XML code or while using code behind.
This code snippet demonstrates the first scenario, when we setup the stretch in the XML. We setup it to `none`, which means that the image will be shown on the screen with its original size.
118
+
119
+
### via code-behind
120
+
40
121
{%snippet img-set-stretch%}
122
+
123
+
The second example shows, how we could set up the property via code behind. In this scenario, we get an instance of the image and set up the appropriate string value. The Image stretch could also be set by using `Stretch` enum. For example:
0 commit comments