Back ground in WPF application can be set using XAML at design time or at run time. Using XAML we do it as follows
<Window.Background> <ImageBrush ImageSource="images\abstract-art-artistic-background-1103970 (1).jpg"/> </Window.Background>
At Runtime
Using some code you can change back ground of WPF /C# application using ImageBrush and BitmapImage object as follows
- Create Uri ,which defines the path of the image
- Using Uri define a bitmap image object which can source for ImageBrush
- Create a BitmapImage object and set the ImageBrush source
- Set Background property with ImageBrush
All the above can be done with inline code as follows
ImageBrush imageBrush = new ImageBrush(new BitmapImage(new Uri("D:\images\abstract-art-artistic-background-1103970 (1).jpg",UriKind.RelativeOrAbsolute))); this.Background = imageBrush;