WPF application resources, content, and data files

Source: Internet
Author: User

MSDN Related information:

http://msdn.microsoft.com/zh-cn/library/aa970494 (v=vs.100). aspx

  • Contents file (content files)
    The content file is simply the combination of pointers and real data, the pointer here means that I need this data, but the data is stored in a file, and will not be compiled, such as being thrown into an EXE or DLL, the advantage is that it will not cause you to compile the file too large, Second, these files can be changed dynamically, but the disadvantage is also obvious, users can arbitrarily delete the files in the form of resources under the project.
  • Using the example
    In addition to the MSDN XAML file as a content resource, the best example is actually a picture, so start with:
    1 UriURI =New Uri("/content/image/eipd.ico", urikind.relative);2System.Windows.Resources.StreamResourceInfoinfo = application. Getcontentstream (URI);3 varIMG =New BitmapImage();4 img. BeginInit ();5Img. Streamsource =info. Stream;6 img. EndInit ();7Info. Stream.Close ();

    First, through the relative path, get to the above-mentioned file "pointer", ready to get the file stream according to this pointer, in fact, the operation of data are "flow" way, we are not familiar with can go to learn well.
    Then, prepare the container where we store the picture: BitmapImage, and then start populating the data.
    Finally, I closed the file stream, which has to be based on the actual operation of the situation, if you need to get very frequently, then you find the opportunity to close. But I think this is the best situation in general, because this sentence will release the use of the file.

WPF application resources, content, and data files

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.