编码设置 Image.Source

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

posted on 2011-05-13 10:32  lzhm  阅读(279)  评论(0编辑  收藏  举报

导航