I have a solution under which so many WPF applications and class library projects are there. I want to use icon in another project which is under Resources folder in other WPF application. how can I achieve this ? I do not want to copy same images over and over in all different projects.
Static Resource - Static resources are the resources which you cannot manipulate at runtime. The static resources are evaluated only once by the element which refers them during the loading of XAML.
WPF supports different types of resources. These resources are primarily two types of resources: XAML resources and resource data files. Examples of XAML resources include brushes and styles. Resource data files are non-executable data files that an application needs.
In Android, a resource is a localized text string, bitmap, layout, or other small piece of noncode information that your app needs. At build time, all resources get compiled into your application. The resources locates inside res directory of your app.
Use pack URI syntax to refer resources. Somethning like this:
<Image Source="pack://application:,,,/Another.Assembly.Name;component/PathToResourceInAnotherProject/YourImage.png"/>
Yes,Microsoft makes that possible for you, as long as Project ABC has a reference to Project XYZ.
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Project XYZ;component/YourSubFolder/YourResourceFile.xaml" />
</ResourceDictionary.MergedDictionaries>
Then you can just use the Resources defined in YourResourceFile.xaml.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With