I have some C# code to load a different image file into the form’s ImageBrush background object at run time but it doesn’t show up in the form at run time as only the default file image (file set at the Control’s properties at design time) showed up in the form’s background.
public runTest()
{
InitializeComponent();
ImageBrush newImage = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Images/new_pix.tif")));
this.Background = newImage;
}
new_pix.tif in ../Images folder has properties-> Build Action-> Resource. This image file is in the same Images folder as the default image file.
My Visual Studio is VS Community 2022, vers 17.11.
.NET ver: 4.8
The code sees the image file location (if I change new_pix.tif to a random named file, it will error out that image file is not found). I don’t know why the new file image doesn’t show up on the form at runtime. TIA!
I expect the new image file would show up in the form’s background at run time, replacing the default image file that was set on the form’s Brush background property.