I need to set the Background of a Stackpanel to some image in the resources.
I know that i should set the background as follows:
Stack.Background= image; // don't know of what type the image should be how to set it
Any help is appreciated,
string fileName = "/Background.png";
BitmapImage image = new BitmapImage(new Uri(fileName, UriKind.Relative));
ImageBrush brush = new ImageBrush();
brush.ImageSource = image;
stack.Background = brush;
StackPanel.Background is of type Brush, and you'll need to create an ImageBrush in order to display an image on the StackPanel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With