c# - how to set background of grid -


I have BitmapImage , and it is set as the Background I want to do this grid I have tried to do this

xaml:

  & lt; Grid X: Name = "content page" & gt; & Lt; Grid.Background & gt; & Lt; ImageBrush X: Name = "IMGbG" /> & Lt; /Grid.Background> & Lt; / Grid & gt;  

C #:

  Bitmap image BMP = new bitmap image (); Bmp.DecodePixelWidth = (int) scrnWidth; Bmp.DecodePixelHeight = (int) ScanHigh; Bmp.SetSource (e.ChosenPhoto); ImageBrush ib = New ImageBrush () {ImageSource = bmp}; ImgBg.ImageSource = ib.ImageSource;  

Output: Output is just black.

Question: I am unable to use the above code as grid element as background code> bitmapmigration < / Code>, am I missing something?

Update I knew when we set the image to background to grid So it works fine:

  ImageBrush ib = new ImageBrush) {ImageSource = bmp}; ContentPanel.Background = IB;  

But I need to use the xaml path, the question is the same.

  & lt; Grid X: Name = "content page" & gt; & Lt; Grid.Background & gt; & Lt; Image Stretch = "None" images = "Your path / source" alignment Y = "center" alignment X = "center" /> & Lt; /Grid.Background> & Lt; / Grid & gt;  

It can help you, you can not promise that it will happen but try it was found on this post


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -