2012-10-31 51 views
4

我想用Windows Installer部署我的VSTO Office Excel加載項。 我創建了安裝程序並在虛擬PC上安裝了加載項來測試它。 現在我有問題,該樣式不工作,但如果我調試或運行它在Visual Studio它確實工作。VSTO Office(Excel)加載項 - WPF XAML樣式,ResourceDictionary

例如,我創造了這樣的風格:以窗口的ResourceDictionary

<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(與它的風格):

<Window.Resources> 
     <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/assembly;component/UI/Resources/Style.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
</Window.Resources> 

它確實只在安裝後工作,當我使用樣式的Keys並將樣式直接設置到控件。


這與樣式的資源字典(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> 

,這裏是 「合併」 -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> 

到資源字典合併到窗口資源,我試圖用:

這些工作時,我調試/運行Visual Studio B UT沒有安裝後:

<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" /> 

這些通常是不工作:

<ResourceDictionary Source="pack://application:,,,/UI/Resources/Style/Skin.xaml" /> 

<ResourceDictionary Source="/UI/Resources/Style/Skin.xaml" /> 

回答

2

我認爲在Source屬性的URI的問題。嘗試使用Pack URIs

+0

我嘗試「Pack URIs」,但它仍然無法正常工作。 – Hiead

+0

你如何儲存你的資源?發佈xaml,還有你正在使用的pack uri –

相關問題