The problem is the way you are using it in code. Just try the below code
public partial class MainView : Window
{
public MainView()
{
InitializeComponent();
ImageBrush myBrush = new ImageBrush();
myBrush.ImageSource =
new BitmapImage(new Uri("pack://application:,,,/icon.jpg", UriKind.Absolute));
this.Background = myBrush;
}
}
You can find more details regarding this in
http://msdn.microsoft.com/en-us/library/aa970069.aspx