WPF 调用资源图片

     最近做的wpf项目中,在开发的时候,把图片放到了bin下面,采用了imagePath =System.IO.Directory.GetCurrentDirectory()+"/images/starShow.jpg";获得图片是可以的,可是发布之后却获取不到图片,这让我很纠结,后来通过把图片添加到了资源中,然后调用资源即可解决了问题

   

      imagePath = "pack://application:,,,/Financial;component/Properties/../images/star/starShow.jpg";

      imageBrush.ImageSource = new BitmapImage(new Uri(imagePath, UriKind.RelativeOrAbsolute));
      imageBrush.Stretch = Stretch.Fill;//设置图像的显示格式 
      btn.Background = imageBrush;

原文地址:https://www.cnblogs.com/shuang121/p/2861515.html