2012-10-18 37 views
1

我正在開發一個自定義的WPF控件庫,其中包含控件轉換器,觸發器和行爲分佈在適當的名稱空間中。我知道如何定義XmlnsDefinition和XmlnsPrefix程序集信息並廣泛使用它。 Hwta我想要做的是迪瓦恩XmlnsPrefix爲相同式組裝內的每個命名空間,以便ForExample如果有聲明,這樣是否有可能在同一個程序集中有多個XmlnsPrefix?

[assembly: XmlnsPrefix("http://schemas.taicodev.com/winfx/2010/xaml/presentation", "TaicoControl")] 
[assembly: XmlnsDefinition("http://schemas.taicodev.com/winfx/2010/xaml/presentation", "CuratioCMS.Client.UI.Converters")] 
[assembly: XmlnsDefinition("http://schemas.taicodev.com/winfx/2010/xaml/presentation", "CuratioCMS.Client.UI.Controls")] 

我要離開TaicoControl但對於轉換器使用TaicoConverter前綴自動

是可能的,沒有在許多不同的程序集中分割程序集,如何實現這一點?

回答

2

如果您希望2個不同的CLR名稱空間使用2個不同的xmlns前綴,則需要爲每個CLR名稱空間定義xmlnsdefinition,以便它使用不同的URI,然後爲每個唯一URI定義xmlnsprefix。

[assembly: XmlnsPrefix("http://schemas.taicodev.com/winfx/2010/xaml/presentation", "TaicoControl")] 
[assembly: XmlnsPrefix("http://schemas.taicodev.com/winfx/2010/xaml/presentation/converters", "TaicoConverters")] 
[assembly: XmlnsDefinition("http://schemas.taicodev.com/winfx/2010/xaml/presentation/converters", "CuratioCMS.Client.UI.Converters")] 
[assembly: XmlnsDefinition("http://schemas.taicodev.com/winfx/2010/xaml/presentation", "CuratioCMS.Client.UI.Controls")] 
+0

這就是真正有效的方法,但是有沒有辦法讓一個XmlnsDefinition像我的情況一樣有一些嵌套的命名空間呢?我的意思是你建議我工作100%,但力量添加到XAML額外的xmlns:ExConverter –

+0

是不是你要求的?轉換器有一個單獨的xmlns前綴?我的意思是你擁有所有東西的原始方式將在單個xmlns前綴下可用。如果您希望爲某人提供某種方式來訪問轉換器,這些方法可以在主xmlns前綴下使用,並且還可以使用單獨的xmlns前綴,則您可以保留所擁有的內容,併爲轉換器定義xmlns定義和xmlns前綴屬性。轉換器。 – AndrewS

+0

謝謝你,它完美的工作 –

相關問題