WPF 之 后台设置Image的Souce

WPF 之 后台设置Image的Souce,第1张

WPF 之 后台设置Image的Souce

  后台动态设置Image的Souce。


方法一:

BitmapImage imgSource = new BitmapImage(new Uri("location",UriKind.Relative));

Image image = new Image();

image.Souce = imgSource;

方法二:

MemoryStream ms = new MemoryStream()

----初始化ms------

BitmapImage imgSource = new BitmapImage();

imgSouce.BeginInit();

imgSouce.StreamSouce = new MemoryStream(ms.ToArray());

imgSouce.EndInit();

Image image = new Image();

image.Souce = imgSource;

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/585780.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存