I have something like this converter with the difference that class is internal and for security the converter belongs to another assembly (MyAssembly.dll):
namespace MyAssembly.InAnotherNameSpace
{
internal class ValueConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
...
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
....
}
}
}
And I use InternalsVisibleToAttribute to access the converter from a WPF project:
....
xmlns:c="clr-namespace:MyAssembly.InAnotherNameSpace;assembly=MyAssembly"
....
<UserControl.Resources>
<ResourceDictionary>
<c:ValueConvertor x:Key="valueConvertor"/>
</ResourceDictionary>
</UserControl.Resources>
I have a problem in XAML, not recognize the class as internal and Visual Studio show this error:
Only public or internal classes can be used within markup. 'ValueConvertor' type is not public or internal.
Follow this answer thread, InternalsVisibleTo not working in XAML, that is true?