Image.Source 如何绑定

来源:互联网 发布:网络虚拟信用卡 编辑:程序博客网 时间:2024/05/21 07:13

编码设置 Image.Source

很多时候,需要编码动态设置显示图片,方法上不是那么直接,从网上找到合适的方法,这里做一下记录。
需要引用的命名空间
System.Windows.Media.Imageing;
代码:
Uri uri = new Uri("image/aaa.png",UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
img.Source = imgSource;
搞定。
原创粉丝点击