If I have an explicit style defined like this:
<Style x:Key="MyButtonStyle1">...</Style>
And a Button control defined like this:
<Button x:Name="MyButton" Style="{StaticResource MyButtonStyle1}" />
Is it possible, at runtime, to extract the style name (i.e., “MyButtonStyle1”) from the button control?
Note: I don’t think looping through the ResourceDictionary will work because, in our app, it will have been cleared and reloaded by the time this code is run.
If you can’t leverage the
ResourceDictionarythen no; you will need theResourceDictionaryto obtain thex:Key.