In a previous question/answer I learnt how data-binding in Windows Phone does TypeConversion for string
to ImageSource
using the TypeConverterAttribute
- see https://stackoverflow.com/a/16753488/373321
I'm now looking at the same problem in WindowsStore apps where TypeConverterAttribute
doesn't exist.
If I use WinRT data-binding then clearly the data-binding layer still manages to do the correct conversion. The MSDN documentation says:
this behavior relies on underlying type conversion that processes the string as a URI, and calls the equivalent of the BitmapImage(Uri) constructor.
However, I can't see any meta-data anywhere about how it knows what conversion to do.
I'm trying to build my own data-binding implementation - so being able to mimic what WinRT does would be very useful.
Is there a queryable metadata hint somewhere which tells the Xaml data-binding what conversion to apply? Or is this string
to ImageSource
conversion somehow baked into the run-time, hidden from the CLR layer?
If it is hidden, is there a list anywhere of known automatic type conversions so that I could cache them in my data-binding implementation?
I discussed this question via Twitter with one of the WinRT devs (Tim Heuer)
A basic summary of this conversation was:
TypeConverterAttribute
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With