I want to deploy my VSTO Office Excel-Add-In with Windows Installer. I created the installer and installed the add-in on the virtual PC to test it. Now I have a problem that the styles do not work, but if I debug or run it in Visual Studio, it works.
For example, I created this style:
<Style TargetType="{x:Type Button}"> <Style.Setters> <Setter Property="Background" Value="Snow" /> <Setter Property="Width" Value="50" /> <Setter Property="Height" Value="25" /> <Setter Property="Margin" Value="5" /> </Style.Setters> </Style>
Now I combine the ResourceDictionary (with the style in it) with the ResourceDictionary window:
<Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/assembly;component/UI/Resources/Style.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources>
It only works after installation, when I use the keys for styles and set the style directly in the control.
This is a ResourceDictionary with styles (Styles.xaml):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type Button}"> <Style.Setters> <Setter Property="Background" Value="Snow" /> <Setter Property="Width" Value="50" /> <Setter Property="Height" Value="25" /> <Setter Property="Margin" Value="5" /> </Style.Setters> </Style> </ResourceDictionary>
And here is the "Merge" -ResourceDictionary:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/ExcelAddIn;component/UI/Resources/Style/Brushes.xaml" /> <ResourceDictionary Source="/ExcelAddIn;component/UI/Resources/Style/ControlTemplates.xaml" /> <ResourceDictionary Source="/ExcelAddIn;component/UI/Resources/Style/Styles.xaml" /> <ResourceDictionary Source="/ExcelAddIn;component/UI/Resources/Style/DataTemplates.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary>
To merge ResourceDictionary into Window-Resources, I tried using:
They work when I debug / run it using Visual Studio, but not after installation:
<ResourceDictionary Source="/ExcelAddIn;component/UI/Resources/Style/Skin.xaml" /> <ResourceDictionary Source="pack://application:,,,/ExcelAddIn;component/UI/Resources/Style/Skin.xaml" /> <ResourceDictionary Source="pack://application:,,,/ExcelAddIn;v1.0.0.0;component/UI/Resources/Style/Skin.xaml" />
As a rule, they do not work:
<ResourceDictionary Source="pack://application:,,,/UI/Resources/Style/Skin.xaml" /> <ResourceDictionary Source="/UI/Resources/Style/Skin.xaml" />