Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 图像控制-从资源文件动态加载图像_Wpf - Fatal编程技术网

Wpf 图像控制-从资源文件动态加载图像

Wpf 图像控制-从资源文件动态加载图像,wpf,Wpf,我在代码中创建了一些图像控件,并希望在此图像控件上设置我保存的一些图片(在创建图像控件之前加载这些图片) 我怎么做 在资源中指定图像,如下所示 <BitmapImage x:Key="SampleImageSource" UriSource="sample.png" /> <Image Source="{StaticResource SampleImageSource}" /> img.Source = (ImageSource) Resources["SampleI

我在代码中创建了一些图像控件,并希望在此图像控件上设置我保存的一些图片(在创建图像控件之前加载这些图片)


我怎么做

在资源中指定图像,如下所示

<BitmapImage x:Key="SampleImageSource" UriSource="sample.png" />
<Image Source="{StaticResource SampleImageSource}" />
img.Source = (ImageSource) Resources["SampleImageSource"];