Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to does WindowsRT Data-binding do type conversion without TypeConverterAttribute

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?

like image 720
Stuart Avatar asked Jun 20 '13 17:06

Stuart


1 Answers

I discussed this question via Twitter with one of the WinRT devs (Tim Heuer)

A basic summary of this conversation was:

  • WinRT does not have anything like TypeConverterAttribute
  • A small number of WinRT controls do have a small number of internal conversions that they will apply
  • There is no information publicly available about which controls and conversions these are
like image 77
Stuart Avatar answered Jan 04 '23 13:01

Stuart