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