Notes for displaying the image. Source attribute in the Silverlight Control

Source: Internet
Author: User

In Silverlight, the image control can be used to display images. The usage is similar to the previous one. Use Image Control
The syntax is as follows:

View code

 <  Grid X: Name  =  "  Layout  "  Width  =  "  250  "  Height  =  "  250 "  Background  =  "  Green  "     >  
< Image X: Name = " Myimage " Source = " /Appletree.png " Stretch = " Uniform " > </ Image >
</ Grid >

Image. Source attributes
The source attribute is used to specify the image position.

View code

<  Image X: Name  =  "  Blue  "  Source  =  "  /Images/dingoslogo.png  "  Stretch  =  "  None  "  />  
< Image X: Name = " Green " Source = " Images/dingoslogo.png " Stretch = " None " />

Note:

1. Images starting with a backslash (Source = "/images/dingoslogo.png") need to be placed in clientbin
In the corresponding folder under the Directory

2. images that do not start with a backslash (Source = "images/dingoslogo.png") should be placed in
The corresponding folder in the Silverlight project directory.

3. The relative path starting with the backslash represents the applicationProgramThe running root directory, that is, in the. xap package, if
If the file to be referenced is not found, the reverse mechanism of the relative path (fallback mechanism) is
It is found in the directory where. xap is located, that is, the clientbin directory for reference. No two locations.
An error occurred. If it does not start with "/", the relative position is the directory of The XAML file that references the image, that is
The directory where the mainpage. XAML file is located.

Image. Stretch attributes
The stretch attribute may have the following values:
1. None
This will not change the image size. If the image size is greater than the container size, the image will be reduced to fit
The container size.
2. Fill
In this case, the image expands to fill the container area. The aspect ratio (width and height ratio) cannot be maintained.
3. Uniform
This is the default value. In this case, the image is adjusted according to the container size, but the aspect ratio remains unchanged. Therefore, it is possible that
The container and image may be blank.
4. uniformtofill
In this case, the image will change the size and fill the container. If necessary, the aspect ratio will be fine-tuned.

Width and height attributes
The width and height attributes of the image overwrite the stretch attributes. If the width and height attributes are specified, the stretch attributes are ignored.
Image. Clip attributes
The clip attribute of the image control is used in Silverlight to determine whether the image is partially displayed or hidden.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.