I’m trying to change the background image set by xaml this way:
<s:SurfaceWindow.Resources>
<ImageBrush x:Key="WindowBackground"
Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/img/bg/Default.jpg"/>
</s:SurfaceWindow.Resources>
by using the following code in a method:
sessionWindow.SetValue(ImageBrush.ImageSourceProperty, "..//..//Resources//img//bg//Aqua.jpg");
where sessionWindow is the the actual window.
It throws the exception in the title
The
ImageBrush.ImageSourceproperty is of typeImageSource.Therefore, you need to set it to an
ImageSourceinstance.Also, your path is wrong.
For example:
However, this won’t actually change the background –
Windowdoesn’t have anImageSourceproperty.Instead, you should set the Window’s
Backgroundproperty, like this: