---
title: "WPF cannot implicitly convert system.drawing.bitmap to media.brush"  
description: "WPF cannot implicitly convert system.drawing.bitmap to media.brush"  
author: "Anonymous User"  
published: 2013-12-18  
updated: 2013-12-18  
canonical: https://www.mindstick.com/forum/1801/wpf-cannot-implicitly-convert-system-drawing-bitmap-to-media-brush  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF cannot implicitly convert system.drawing.bitmap to media.brush

I want to change the [background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp) of a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) manually in my [WPF](https://www.mindstick.com/forum/304/wpf) app.

I have an [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) imported into my [resources](https://yourviews.mindstick.com/view/293/renovation-causes-wastage-of-resources) and I want to do:

MyButton.Background = MyProject.Properties.Resources.myImage;

But I get the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing):

[cannot implicitly](https://www.mindstick.com/forum/34469/cannot-implicitly-convert-type-long-to-long) [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) system.drawing.bitmap to media.brush

How can I do this??

## Replies

### Reply by Anonymous User

Hi Jay,\

You can create a BitmapImage from a Pack URI to that file.

you have to create an ImageBrush from the BitmapImage to set the Background property.

```
var uri = new Uri("pack://application:,,,/images/myImage.jpg");var image = new BitmapImage(uri);MyButton.Background = new ImageBrush(image);
```


---

Original Source: https://www.mindstick.com/forum/1801/wpf-cannot-implicitly-convert-system-drawing-bitmap-to-media-brush

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
