使用代码创建WPF图片

//动态生成图片
Image avatar = new Image();
avatar.Width = 100 - randomSize*5;
avatar.Height = 100 - randomSize*5;
avatar.Source = new BitmapImage(new Uri(imageUrl));
avatar.Stretch = Stretch.Uniform;