If I have the following code:
Style defaultStyle = (Style)FindResource('MyTestStyle');
Is there a way to get the name of the style (i.e. reverse-lookup)? Something like:
string name = defaultStyle.SomeMagicLookUpFunction()
Where name would evaluate to ‘MyTestStyle.’
Is this possible?
I’ve created a small helper class with a single method to do the reverse lookup that you require.
you can call it using the following
Every
FrameworkElementhas it’s own.Resourcesdictionary, using ‘this’ assumes you’re in the right place for where MyTestStyle is defined. If needs be you could add more methods to the static class to recursively traverse all the dictionaries in a window (application ?)