2009-05-17 74 views
0

我想了解更多關於WPF的知識。我瀏覽了一個創建按鈕的在線教程,然後創建了一個應用於其他按鈕的模板。問題是這個模板在Window.xaml中,我只能從該應用程序中訪問模板。如何使模板更具全局性?我想通過某種方式引用xaml,就像您可以從不同的項目或解決方案中引用程序集一樣。分享WPF控件模板

回答

1

你可以用它在你App.xaml中引用這樣的(Expression Blend中自動完成它)「資源字典」:

<Application.Resources> 
    <!-- Resources scoped at the Application level should be defined here. --> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="ResourceDictionary1.xaml"/> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

如何從其他程序集引用的資源,使用包URI語法。 This link也涵蓋了它。