Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Help with loading an image to label' background C# WPF

$
0
0

Hi,

I've created a class named: Structure which inherits from label.
I want to dynamically load an image to it's background from the project' resources folder:

this is the part inside the CTOR where I was trying to do so (and crashed):

ImageBrush ib = new ImageBrush();
            ib.ImageSource = new BitmapImage(new Uri(@"/GameProjectV2BaseCitySimulation;component/Resources/catspraying.jpg"));

            this.Background = ib;
            Canvas.SetTop(this, 100);
            Canvas.SetLeft(this, 100);
I get this error:
URi illegal - there was no option to determine what is the URi form...

What am I missing?

Thanks on advance!
Best Regards,
Eyal :)  

Best Regards, Ang :)


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>