2

We are creating an office ribbon that opens up a WPF window that is stored in another WPF Control library project. That WPF window has some themes attached to it that is stored in a ResourceDictionary that is compiled in a separate project.

However when we load up the WPF window, all the themes from the ResourceDictionary are lost.

We can fix this by manually/forcing the theme on the window itself, but this seems like a bad solution. So my question is: how can I load the theme of the new WPF window from the Office Addin application?

Uri uri = new Uri("/Nov.Presentation.RigDoc.WpfResources;component/Shared.xaml", UriKind.Relative); Resources.MergedDictionaries.Add(Application.LoadComponent(uri) as ResourceDictionary); 
2
  • Is this of any use to you? stackoverflow.com/questions/977981/… Commented Jun 16, 2009 at 12:37
  • Thanks for the reply! Yes and no, this is what I am using but when I open the window from an Office app the styles disappear because its not running in the WPF application scope. Commented Jun 17, 2009 at 14:45

1 Answer 1

3

I just tried this with Office 2010 (actually using a 2007 VSTO Addin but running it in 2010) and it works perfectly. I´ve got an external project´s library referenced in the VSTO project and I use this following xaml in the control to link in the resource dictionary.

<UserControl.Resources> <ResourceDictionary> <!-- Link in th general styles --> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MyAssemblyName;component/MyResourceDictionaryName.xaml" /> </ResourceDictionary.MergedDictionaries> <!-- Other style... --> </ResourceDictionary> </UserControl.Resources> 

Otherwise I could think of it being a problem with your styles being overrided by some later explicit or implicitly linked in styles. If it cannot find the assembly you reference it should throw an example so the problem shouldn't be therein.

Sign up to request clarification or add additional context in comments.

Comments