Summarize the WPF image source bindings in several ways

Source: Internet
Author: User

Absolute path:

Code BitmapImage image = New BitmapImage (New Uri ("E:\\project\\xxx.png", Urikind.absolute));

Imgname.source = image;

XAML: <image name= "imgname" Sourcee:\\project\\xxx.png ">

relative path :

1): Referencing resources from other assemblies

<image name= "tb_1" source= "/yiou.hospital.platform.resource; Component/image/toleft.png ">

    "/yiou.hospital.platform.resource; Name of other assembly
Component fixed notation

2) directory under the project

Imgname.source = new BitmapImage (New Uri (pack://application:,,,/resources/aa.jpg));

Pack://application:,,, This is also a fixed notation, Imgname.source = new BitmapImage (new Uri (/aa.jpg)), without explicit write-up, will automatically add

There are other binding methods that can bind the stream and later add

Summarize the WPF image source bindings in several ways

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.