PVi*_*itt 19 wpf image wpf-controls
我想使用wpf图像控件显示文件中的图像.映像文件驻留在应用程序目录中.
<Image Stretch="Fill" Source="dashboard.jpg" />
Run Code Online (Sandbox Code Playgroud)
dashboard.jpg在部署期间或之后,该文件应该是可替换的.我如何将图像添加到项目中以及必须使用哪些BuildAction来从文件系统读取图像,而不是在部署后无法更改的任何源.我必须使用什么来源uri?
Rud*_*att 26
ImageSource imageSource = new BitmapImage(new Uri("C:\\FileName.gif"));
image1.Source = imageSource;
Run Code Online (Sandbox Code Playgroud)
bat*_*tey 19
在标记中:
<Image Stretch="Fill">
<Image.Source>
<BitmapImage UriSource="dashboard.jpg"/>
</Image.Source>
</Image>
Run Code Online (Sandbox Code Playgroud)