silverlight imagesource赋值与转换

介绍几种常用的Image source 赋值方式:

this.abc.Source = new BitmapImage(new Uri("/1.jpg", UriKind.RelativeOrAbsolute));
Uri uri = new Uri("1.jpg", UriKind.Relative);
ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(uri);   
this.abc.SetValue(Image.SourceProperty, imgSource);
this.abc.Source = new BitmapImage(new Uri("F:\\1.jpg", UriKind.RelativeOrAbsolute));

/{程序集名};component搜索/{图片资源路径}

 var uri = new Uri("/AppleMenu;component/Res/" + value + ".png", UriKind.Relative);
                IconImage.Source = new System.Windows.Media.Imaging.BitmapImage(uri);

 

posted @ 2015-01-31 23:12  童心少年  阅读(160)  评论(0编辑  收藏  举报