如何从根文件夹中提供图像控制的图像路径? [英] How to give image path of image control from root folder ?
本文介绍了如何从根文件夹中提供图像控制的图像路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给路径
i want to give path as
image1.Source = new BitmapImage(new Uri("Images\1.png"));
怎么可能,请告诉我是否有人可以。
我是什么尝试过:
我在wpf中的当前图像路径代码是
how it is possible , please tell me if anyone can.
What I have tried:
My current image path code in wpf is
image1.Source = new BitmapImage(new Uri(@"D:\My Work\Programming\wpf\Number Generator\Number Generator\Images\1.png"));
推荐答案
尝试:
Try:
image1.Source = new BitmapImage(new Uri(Path.Combine(Application.StartupPath, "Images\1.png")));
这篇关于如何从根文件夹中提供图像控制的图像路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文