Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
Referencing Styles Within IG DLLs
posted

Forgive me if this question is answered already or documented elsewhere, but I have yet to find an answer.

Backstory:

I'm using the IG theme in my application. I wish to make a very small modification to the XamComboEditor template. I have found the template for it in "C:\Program Files (x86)\Infragistics\2015.1\WPF\Themes\IG\IG.xamComboEditor.xaml". Upon copying the template into my application for some modifications I get build errors on the brushes and colors used by the template.

Now, I know I can just copy the necessary xaml files into my application and reference them via a MergedDictionary, but I can't help but feel that there is a more elegant solution.

Now, I have a class library with some controls and shared styles in it. In order to use that in my primary application, I merely add the following at the top of my user control.

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/CommonLibrary;component/Themes/CommonStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>

My question is, is this possible with the IG DLLs? My attempts at it have failed thus far. Is there perhaps a more elegant solution?

Here's what I'm hoping to do in order to get access to the brushes and colors for the theme:

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/CommonLibrary;component/Themes/CommonStyles.xaml" />
                <ResourceDictionary Source="/InfragisticsWPF4.Themes.IG.v15.1;component/Themes/IG/Styles.Shared.xaml" />
            </ResourceDictionary.MergedDictionaries>

Or do I need to do something like the following?

<ResourceDictionary Source="pack://application:,,,/InfragisticsWPF4.Themes.IG.v15.1;component/Themes/IG/Styles.Shared.xaml" />

Is there a way to do it that is agnostic of the version? Or does the version utility find and upgrade such lines?

Parents
  • 6759
    Verified Answer
    Offline posted

    Hi Kristopher,

    One of the options you have is to use the ThemeManager framework to apply a certain theme. With it you simply have to execute the following line to apply a theme application wide:

    Infragistics.Themes.ThemeManager.ApplicationTheme = new IgTheme();

    The ThemeManager will track which IG controls are being used and will import their styles into the application resources.

    If you need to import the resourse dictionaries manually you could check out the attached sample. In a nutshell I've created CustomResourceDictionary class tha iherits ResourceDictionary. This customeRD have two more props - Location and TypeFromHostingAssembly. The Location prop is expecting to geth the locatioon of the xaml file relative to the assembly it's contained in. TypeFromHostinAssembly is expecting a reference to type that is defined in the assembly containing the xaml styles. So the usage lookes like the following:

    CustomRecourceDictionary.zip
Reply Children
No Data