1. Use memeorystream
1 Imagebrush backbrush = New Imagebrush (); 2 Bitmapimage Bi = New Bitmapimage (); 3 Bi. begininit (); 4 Memorystream MS = New Memorystream (); 5 Imove. App. eastonline. properties. Resources. Background. Save (MS, imageformat. BMP ); // System. Drawing. image; 6 Ms. Seek ( 0 , Seekorigin. Begin ); 7 Bi. streamsource = MS; 8 Bi. endinit (); 9 Backbrush. imagesource = Imaging. createbitmapsourcefromhbitmap (hbitimage, intptr. Zero, int32rect. empty, 10 Bitmapsizeoptions. fromemptyoptions ()); 11 Backbrush. Stretch = Stretch. Fill; 12 This . Background = backbrush;
2. Use Imaging
Imagebrush backbrush =NewImagebrush (); intptr hbitimage=Imove. App. eastonline. properties. Resources. Background. gethbitmap (); backbrush. imagesource=Imaging. createbitmapsourcefromhbitmap (hbitimage, intptr. Zero, int32rect. Empty, bitmapsizeoptions. fromemptyoptions (); backbrush. Stretch=Stretch. Fill;This. Background = backbrush;