TheTanic
TheTanic

Reputation: 1638

Path to Custom Resource Folder

I created a new Folder in my Class-Library Project, calles "Resources". There i added an icon with the name "icon.png".
The properties of the icon are:
Build Action: Embedded Resource
Copy to Outpur Directory: Copy always

Now i want to use the icon in my Library and in the project, which has a reference to the .dll of the Library.

I already tried to get it with the BaseUri + "Resource/icon.png", but the complete Resource-Folder isn´t copied, when I build the Class-Library.

So how can I setup my Class-Library, that I can get the Icon/Resource-Folder in my Library and in projects, that reference to the .dll.

Upvotes: 0

Views: 176

Answers (1)

Juan Pablo Garcia Coello
Juan Pablo Garcia Coello

Reputation: 3232

You can set the image as Content and Do not copy or Embedded Resource and Copy always and read it in XAML:

  <Image Source="ms-appx:///ClassLibraryNamespace/Resources/icon.jpg"/>

where ClassLibraryNamespace is your library name.

In code behind is the same with a

Source = new Uri("ms-appx:///ClassLibraryNamespace/Resources/icon.jpg");

Remember that are 3 slashes in the application path.

Upvotes: 1

Related Questions