I have a WPF custom user control that is used in a Windows Application. The control has a border as the main element, and this border has a default background image. The code below shows how this image is set as a default. The default image is a resource element (Images/BlueRoad.jpg).
I want to be able to programmatically change the image of the border background using an image filename as string (e.g. "C:\Pictures\myCustomPic.bmp"). I need to do this in code-behind using Visual Basic, unless there is a VERY simple way to do it in XAML. Either way, the picture will load in the startup code for the control.
I do not know much about WPF and this is just a small element of the application, so want to get this done as simply and quickly as possible.
Many Thanks!
<Border Name="mainBorder" Opacity="1" BorderBrush="SteelBlue" BorderThickness="3">
<Border.Background>
<ImageBrush ImageSource="Images/BlueRoad.jpg"></ImageBrush>
</Border.Background>
Grid and other stuff goes here...
</Border>