In the assembly action, you can mark the image file as content or as a resource. The syntax for using an image in ImageBrush differs depending on which one you choose.
Here is the image file marked as content .

To set the button background to this image, use the following code.
var brush = new ImageBrush(); brush.ImageSource = new BitmapImage(new Uri("Images/ContentImage.png",UriKind.Relative)); button1.Background = brush;
Here is the image file marked as a resource .

To set the button background to the resource image, use the following code.
Uri resourceUri = new Uri("Images/ResourceImage.png", UriKind.Relative); StreamResourceInfo streamInfo = Application.GetResourceStream(resourceUri); BitmapFrame temp = BitmapFrame.Create(streamInfo.Stream); var brush = new ImageBrush(); brush.ImageSource = temp; button1.Background = brush;
source share