且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在文件夹中找到图像

更新时间:2023-09-26 11:58:34

将图像文件的构建操作设置为资源,并通过资源文件包URI

Set the image file's Build Action to Resource, and load it by a Resource File Pack URI:

var path = $"pack://application:,,,/FamFamFam.Flags.Wpf;component/Images/{countryId.ToLower()}.png";
var bitmap = new BitmapImage(new Uri(path));