更新时间: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));