Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use wpf image control to show an image from filesystem

Tags:

I want to show an image from a file using an wpf image control. The image file resides in the application directory.

<Image Stretch="Fill" Source="dashboard.jpg" />

The file dashboard.jpg should be replaceable during or after deployment. How do I have to add the image to the project and what BuildAction do I have to use to have the image read from the file system rather than any source I cannot change after deployment. What source uri do I have to use?

like image 487
PVitt Avatar asked Dec 02 '10 07:12

PVitt


People also ask

What is a viewbox in WPF?

The Viewbox control is used to stretch or scale a child element.

What is the meaning of WPF?

WPF, stands for Windows Presentation Foundation is a development framework and a sub-system of . NET Framework. WPF is used to build Windows client applications that run on Windows operating system. WPF uses XAML as its frontend language and C# as its backend languages.


1 Answers

ImageSource imageSource = new BitmapImage(new Uri("C:\\FileName.gif"));    
image1.Source = imageSource;
like image 174
Rudresh Bhatt Avatar answered Oct 03 '22 16:10

Rudresh Bhatt