code_junkie

WPF image resources

Nov 12th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <Image Source="..MediaImage.png" />
  2.  
  3. <Image Source="/WPFApplication;component/Images/Start.png" />
  4.  
  5. doGetImageSourceFromResource ("[YourAssemblyNameHere]", "[YourResourceNameHere]");
  6.  
  7. static internal ImageSource doGetImageSourceFromResource(string psAssemblyName, string psResourceName)
  8. {
  9. Uri oUri = new Uri("pack://application:,,,/" +psAssemblyName +";component/" +psResourceName, UriKind.RelativeOrAbsolute);
  10. return BitmapFrame.Create(oUri);
  11. }
  12.  
  13. <BitmapImage x:Key="MyImageSource" UriSource="Resources/Image.png" />
Add Comment
Please, Sign In to add comment