As a WPF developer you might have seen the resource reference in the form
pack://application:,,,/somefile.xaml
and you might have used this style too.Actually what is this pack uri ?
This is a new method introduced in WPF to locate files in an assembly or in the current folder.Those files may be images,videos,audio and even another xaml file.
Parts
The first part identifies whether it points to an application or to the current folder where the file is located and the second part is the relative path to that file.
First part can be any one of the following
pack://application:,,,/somefile.xaml
and you might have used this style too.Actually what is this pack uri ?
This is a new method introduced in WPF to locate files in an assembly or in the current folder.Those files may be images,videos,audio and even another xaml file.
Parts
The first part identifies whether it points to an application or to the current folder where the file is located and the second part is the relative path to that file.
First part can be any one of the following
- application -> Tells that the file is located in the assembly as Content or Resource pack://application:,,,/ResourceFile.xaml
- siteoforigin -> Its in the current executing folder pack://siteoforigin:,,,/SiteOfOriginFile.xaml
Second part tells the assembly where the file is located.If the file locate in same assembly there is no need to mention it other wise use assembly name
Same assembly - pack://application:,,,/ResourceFile.xaml
Different assembly - pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
Same assembly - pack://application:,,,/ResourceFile.xaml
Different assembly - pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
pack://application:,,,/ReferencedAssembly;v1.0.0.1;component/ResourceFile.xaml
Fourth part is the path to file.
pack://application:,,,/Subfolder/ResourceFile.xaml
Advantage of pack uri style
- You may separate your styles from application and keep as dll.
- Design time support