“value does not fall within the expected range” XAML exception using DataTemplateSelector

For the record I made a stupid error in Xaml and got bashed with the usual unhelpful error message (no stack trace, no line numbers just the message you see above).

I’d created a custom DataTemplateSelector but rather than set the ItemTemplateSelector property on the GridView, I’d put it inside the . Nothing complained but the app threw a runtime exception as above.

Instead putting the DataTemplateSelector as a static resource and setting ItemTemplateSelector=”{StaticResource myTemplateSelector}” resolved the problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s