//传给Image
var ste = WebRequest.Create("https://www.baidu.com/img/logo-yy.gif").GetResponse().GetResponseStream();
Image myImg = new Image();
myImg.Source = BitmapFrame.Create(ste, BitmapCreateOptions.None, BitmapCacheOption.Default);
//做控件背景,WindowGrid是控件名
WindowGrid.Background = new ImageBrush
{
ImageSource = new BitmapImage(new Uri("https://www.baidu.com/img/logo-yy.gif", UriKind.RelativeOrAbsolute)),
Stretch = Stretch.Uniform
};