I have a simple WPF window. I intend to set it's background to be one of the images I added to project as Embedded Resource. This is what I tried:
<Window x:Class="A_Boggle.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="A-Boggle" Height="300" Width="625" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Name="Game"> <Window.Background> <ImageBrush ImageSource="background.jpg"></ImageBrush> </Window.Background> <Grid> </Grid>
But with this, i always get this: "Error 1 The file splash.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'."
Any ideas?
In this article, you will learn how to develop background image in Univesal Windows Platform Application, using XAML and C sharp program. Requirements - Visual Studio 2015 Update 3. Step 1 - Open Visual Studio 2015 Update 3 and open the new project. The shortcut key, which can be used is Ctrl+Shift+N.
Go to the image within VS and set the item to be a Resource. Right click -> Properties -> Build Action -> Resource
Update:
You need to change the path if it is in a folder. ie...Resources/background.jpg
you can use this in main.xaml.cs
InitializeComponent(); ImageBrush myBrush = new ImageBrush(); myBrush.ImageSource = new BitmapImage(new Uri("F://13.png", UriKind.Absolute)); this.Background = myBrush;
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