How do I set a Background on a wpf form from Resources?

this.Background =  
    new ImageBrush(new BitmapImage(
        new Uri(@"pack://application:,,,/Stream;component/images/empty.png")));

Doesn't work! I get an IOException, that says Cannot locate resource, My project's name is stream, even my assembly name and default name space...please help...

or if there's an alternative like converting the Bitmap Image to ImageSource please tell me..

Upvotes: 0

Views: 633

Answers (1)

Eli Arbel
Eli Arbel

Reputation: 22739

Check the Build Action on empty.png (right click the file in Solution Explorer and select Properties). It should be Resource (not Embedded Resource).

Upvotes: 3

Related Questions