天天看點

WPF BitmapImage 從資源檔案中使用Uri加載圖檔

WPF BitmapImage 從資源檔案中使用Uri加載圖檔

1、圖檔生成操作設定為Resource

WPF BitmapImage 從資源檔案中使用Uri加載圖檔

2、設定Uri

Uri uri = new Uri(“pack://application:, , ,/UriDemo.Demo;component/common/Images/” + name + “.png”)

WPF BitmapImage 從資源檔案中使用Uri加載圖檔

3、顯示圖檔

BitmapImage image = new BitmapImage(new Uri(“pack://application:,/UriDemo.Demo;component/common/Images/” + name + “.png”));