Search code examples
wpf

How to fix "Shared attribute in namespace ...... can be used only in compiled resource dictionaries" error when using XAML in a dll?


Shared attribute in namespace 'http://schemas.microsoft.com/winfx/2006/xaml' can be used only in compiled resource dictionaries.

How to get out from this error, when working with xaml in dll/class library ?


Solution

  • Check if this helps

    http://social.msdn.microsoft.com/Forums/en/wpf/thread/216762d4-ce21-4888-8d98-bbe4d30f7a03

    In summary, Shared is only legal under the following conditions:

    • The ResourceDictionary that contains the items with x:Shared must be compiled.
    • The ResourceDictionary cannot be within loose XAML or used for themes
    • The ResourceDictionary that contains the items must not be nested within another ResourceDictionary. For instance, you cannot use x:Shared for items in a ResourceDictionary that is within a Style that is already a ResourceDictionary item