[自定義控制元件 Wpf 庫]
Test
-->Resources
-->Resources
-->Dictionary1.xaml (Reusable across multiple project)
-->Dictionary2.xaml(Reusable across multiple project)
[WPF 主界面] TestRD
-->Resources
-->Resources
-->Dictionary9.xaml(Specific to the project)
XAML:Dictionary1.xml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="brush" Color="Red"/>
</ResourceDictionary>
Dictionary2.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="brush" Color="Green"/>
</ResourceDictionary>
Dictionary9.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--How can I use the resource from another DLL here-->
</ResourceDictionary>
如何在 Dictionary9 中參考 Dictionnary1 或 dictionary2?
是否可取,尤其是在模塊化專案中?
我有一些樣式我想在全球范圍內移動,這樣我就可以重復使用并停止復制和粘貼它們。
uj5u.com熱心網友回復:
- 如何在 Dictionary9 中參考 Dictionnary1 或 dictionary2?
嘗試這個:
Dictionary9.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--How can I use the resource from another DLL here-->
<ResourceDictionary Source="pack://application:,,,/Resources;component/Resources/Dictionary1.xaml" />
<ResourceDictionary Source="pack://application:,,,/Resources;component/Resources/Dictionary2.xaml" />
</ResourceDictionary>
請注意,第一個“資源”是您的庫名稱,第二個“資源”是您的庫中的檔案夾名稱。你可以在這里找到更多資訊。
- 是否可取,尤其是在模塊化專案中?
IMO,如果您要重用或需要分開這些字典,那完全沒問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/506343.html
標籤:xml
