views:

70

answers:

1

I have a ListBox and a lot of templates that override/extend each other. How can I check from code-behind, what template currently affects my ListBox?

I can access ListBox from code-behind, its Template property gives type of control this template is for, how to get Name of this template? Same about styles.

A: 

When you say "get Name of this template" do you mean getting the key the template used in its ResourceDictionary ?

If you're looking for the key, I don't think there is a way to grab it, because when you apply the template to your control, you use a StaticResource or a DynamicResource markup extension that make the resolution (from the key) for you. Once the resource has been found in the ResourceDictionary, it is applied to the control and the key is no longer used.

Jalfp