101 ICON "images\\Application.ico" 102 ICON "images\\Document.ico" 103 ICON "images\\Help.ico"
C:\> rc App.rc
App.res
to the project (leave None
as the Build Action
).Source: StackOverflow: Dmitry Schechtman, "Embed multiple icons in WPF EXE"
In XAML, to reference an image in images/icons/icon-product-acme1.png
in assembly Acme.Products.Specifications.dll
, you need to use the pack
notation (for package).
Local Assembly (no pack
notation required):
<Image Source="/images/icons/icon-product-acme1.png" Width="35" Height="35" Margin="5" />
Referenced Assembly:
<Image Source="pack://application:,,,/Acme.Products.Specifications;component/images/icons/icon-product-acme1.png" Width="35" Height="35" Margin="5" />
NOTE: Make sure the image file is compiled as Resource
(not Embedded Resource
or Content
) in the assembly.
Assets\FormDictionary.xaml
: <ResourceDictionary xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--Control colors.--> <Color x:Key="WindowColor">#FFE8EDF9</Color> <Color x:Key="ContentAreaColorLight">#FFC5CBF9</Color> <Color x:Key="ContentAreaColorDark">#FF7381F9</Color> . . . </ResourceDictionary>
PresentationCore
PresentationFramework
WindowsBase
<ResourceDictionary xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:p="clr-namespace:AHI.App.Localization;assembly=AHI.App.Localization"> <!--Control colors.--> <Color x:Key="WindowColor">#FFE8EDF9</Color> <Color x:Key="ContentAreaColorLight">#FFC5CBF9</Color> <Color x:Key="ContentAreaColorDark">#FF7381F9</Color> . . . </ResourceDictionary>
ResourceDictionary
files can be merged together in App.xaml
so these resource are available for all controls in the application:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="MyApp"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Assets/FormDictionary.xaml" /> <ResourceDictionary Source="AHI.App.Resources;component/MainDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>