TryFindResource returning non-null value on unfound resource
Posted: 01 Sep 2013, 21:11
I am trying to gracefully handle loading resources which may not exist within my xaml files.
According to the documentation:
According to the documentation:
This is happening correctly. I don't want exceptions thrown though so I am using TryFindResource. According to the documentation:If a resource was requested by a FindResource call, and was not found, an exception is raised.
However no matter what I provide for an invalid key, this always returns a non null value to a BaseComponent with a class id of "UnsetValue". I can use this to differentiate between existing and non-existing resources but I am unclear why I am not getting a null value from TryFindResource when a call to FindResource with the same key to a non-existent resource throws an exception.If a resource was requested by a TryFindResource call, and was not found, no exception is raised, but the returned value is null.