0

I'm looking for a method to make all my resource files work properly after I have written my project in a cd.

For example I have saved my images in Project Name\Project Name\obj\Debug\Images and I want them to be usable both in xaml and regular c# code, when I insert that cd in another machine.

Thanks for your time!

Xenofonos
  • 119
  • 1
  • 2
  • 14
  • Whether you write to a CD or Copy to your pendrive or do whatever.. It should work if you have save the image as resource. Check [this](http://stackoverflow.com/questions/25714085/wpf-import-image-as-resource) and [this](http://wpf.2000things.com/2014/07/03/1107-accessing-an-embedded-resource-using-a-uri/) – Abhinav Sharma Mar 03 '16 at 11:33
  • I got it to work in c# but I'm still having trouble in xaml.. – Xenofonos Mar 04 '16 at 00:04
  • Please post some code.How can somebody figure out what is wrong? Does it work in the xaml before writing to CD? – Abhinav Sharma Mar 04 '16 at 04:44

1 Answers1

0

What worked for me was, using the Image class for both backgrounds and overlapping images.

In xaml the code is <Image x:Name="Image1" Source="..\obj\Debug\Images\image.jpg"/>

and you initialise it in c# using

public PageName()
        {
            InitializeComponent(); 
            Image1.Source = new BitmapImage(new Uri(@"../Images/cafeteria.jpg", UriKind.Relative));                        
        }

It's a shame because (atleast in my case) the ImageBrush Class didn't support relative uris for some reason..

Xenofonos
  • 119
  • 1
  • 2
  • 14