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

using resource dictionary as central collection of all images

$
0
0

Hello guys,

i have a project with a lot of assemblies (> 100). many of those assemblies have subfolders like "images". many wpf-windows/user-controls for example have a "\images\close.png". that means that i have many "close.png" pictures instead of just a single one.

now i want to create a central place for all images/resources. what i did:

  • created a new class-libary/assembly called "a.b.c.d.e.Core.Resources"
  • added a resourcedictionary called "ImageDictionary.xaml"
  • created a subfolder "Images"
  • copied my images to this subfolder. for example "a.b.c.d.e.Core.Resources\images\close.png"
  • setting the built property of the image to "resource"
  • declared the image in the "ImageDictionary.xaml" like this "< ImageSource x:Key="Image_close">close.png< /ImageSource>"
  • using the dictionary in the wpf window where i want to use the "close.png" image like this

    < Window.Resources> < ResourceDictionary Source="pack://application:,,,/a.b.c.d.e.Core.Resources;component/Images/ImageDictionary.xaml"/> < /Window.Resources >

  • trying to use the image declared in the central resource dictionary "ImageDictionary.xaml" like this < Button>< Image Source="{StaticResource Image_close}">< /Image>< /Button>

in the designer mode of VS the image is beeing displayed but when i start the project and open my wpf window i get an error like

"{"The File or Assembly \"a.b.c.d.e.Core.Resources, Culture=neutral\" or one of its dependencys can't be found. The system can't find the given file.":"a.b.c.d.c.e.Resources, Culture=neutral"} (i translated the error message from german to english :) )

Does anyone have any idea what i did wrong and why i can't get the central resourcedictionary getting to work properly? Thanks for any ideas!!!

Greetings from Germany

edit: i also have a reference to "a.b.c.d.e.Core.Resources" in the assembly where my wpf window is

edit 2:System.Windows.Markup.XamlParseException: Message=RowNumber "7" und RowPosition "10" von "Setting the Property "System.Windows.ResourceDictionary.Source" caused an exception".


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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