Wednesday, July 2, 2008

About pack uri style

As a WPF developer you might have seen the resource reference in the form


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.


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

      Third part is the version and this is optional


      Fourth part is the path to file.


      Advantage of pack uri style

      • You may separate your styles from application and keep as dll.
      • Design time support
      What msdn says