So I try to apply an image but cannot see any changes...
What do I am missing? Thanks!!
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(@"pack://application:,,,/Images/bg1.jpg", UriKind.RelativeOrAbsolute);
bi.EndInit();
ImageBrush ib = new ImageBrush();
ib.TileMode = TileMode.Tile;
ib.ImageSource = bi;
ib.Stretch = Stretch.None;
RootGrid.Background = ib;
Try this instead:
var ib = new ImageBrush {
ImageSource =
new BitmapImage(
new Uri(@"Images\bg1.jpg", UriKind.Relative)
)
};
RootGrid.Background = ib;
Also, this is obvious, but make sure the image is actually at the right path and set to be Content in the Project.
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