Set Image Source in WPF

Posted on: Tue Aug 04 12:32:32 -0700 2009. Updated on: Thu Aug 06 11:04:16 -0700 2009.
Category: WPF

Setting the Image.Source property in WPF. Note this is slightly different than in silverlight because it requires an object holding the image data as source.


private void SetPageViewImage(string sourceFile)
{
	Uri uri = new Uri(sourceFile, UriKind.Relative);
	ImageSource imgSource = new BitmapImage(uri);
	PageViewImage.Source = imgSource;
	PageViewImage.Visibility = Visibility.Visible; //optional
}

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.