Closed rdadkins closed 4 years ago
Put more simply, TypeConverterHelper.Convert is trying to convert from IList<object>
to IList<MyType>
but MyType
has assembly information attached to it. Thus, both the scope and type is incorrect due to a .
found in the assembly version.
If you look at the source code for TypeConverterHelper
you will see it actually uses XamlReader
to perform the type conversion and that is via a XAML bit of code.
Unfortunately, generics are only supported in XAML 2009 but UWP is based on XAML 2006 so there is no way for us to use it.
The easy way to fix this problem is to just create your own type based on List<T>
and use it on the property types, like so:
public class MyCollection: List<MyType>
{
public MyCollection() : base()
{
}
public MyCollection(IEnumerable<MyType> collection) : base(collection)
{
}
public MyCollection(int capacity) : base(capacity)
{
}
}
Closing this for now, feel free to open if you have difficulties applying this solution.
Take the following example:
Custom collection converter: an
IValueCoverter
that attempts to convert anIList
to anIList<T>
whereT
is the type specified by the converter parameter.The issue:
TypeConverterHelper
does not support types found in other assemblies (the privateGetType(string)
is the cause).If the destination type is
IList<MyType>
, thename
passed toTypeConverterHelper.GetType
would look like:GetType(string)
implementation ofLastIndexOf(".")
does not account for the assembly qualified name being included and thus resulting in an invalid type being parsed.