2009-08-02 74 views
2

嗨我想在DLL中創建一個可重用的XAML窗口。如何使用DLL中存在的ResourceDictionary設置XAML窗口的樣式?

我已經在Themes文件夾中放置了一個新的ResourceDictionary(我甚至將它合併到了Generic.xaml中),但是當我嘗試在窗口中使用它的樣式時,我收到一條錯誤消息,指出樣式不存在:

<Window Style="{StaticResource ModalWindowStyle}" > 
    <!-- I have also the following --> 
    <Window.Resources>  
     <Style TargetType="Button" BasedOn="{StaticResource ButtonStyle}" /> 
    </Window.Resources> 
</Window> 

我得到一個異常,這種風格是不存在的,他們都在ResourceDictionary中這是在主題文件夾中聲明。

+1

您是否在XAML文件中引用了資源字典? – Charlie 2009-08-02 17:41:06

回答

0

this post

...只要項目B有一個參考項目A.

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="/Project A;component/YourSubFolder/YourResourceFile.xaml" /> 
</ResourceDictionary.MergedDictionaries> 

然後,你可以使用YourResourceFile.xaml定義的資源。

相關問題