Rediscovering the Obvious

…stumbling in the footsteps of greatness

Pack Notation for style merging

without comments

Just so I remember (Company.Product.Module is the naming convention we use for both namespaces and assemblies)  

                <ResourceDictionary Source=”pack://application:,,,/Company.Product.Module;component/AppStyles.xaml”/>

The code for loading this into the application resources during startup is:

        // In App : Application
        protected override void OnStartup(StartupEventArgs e)

            Uri uri = new Uri(“pack://application:,,,/Company.Product.Module;component/AppStyles.xaml”);
            ResourceDictionary rd = new ResourceDictionary();
            rd.Source = uri;


If you wish to use Application.Current.LoadComponent( uri ), however, it fails with an error that absolute URI’s are not allowed.  This pack:// naming convention was a bear to figure out the details, and several of the examples provide by the MSDN text do not work.

More information on the pack notation in WPF at

[UPDATE2] has a lot more information on this.

Written by erwilleke

April 3rd, 2007 at 4:06 pm

Posted in Uncategorized

Leave a Reply