Is there a way to define a style that is applied to an object only in certain cases?
For example: A style for labels that are part of an item template in a listbox.
I know you can create a key for a style and specify what style to apply to the label directly, but is there another more generic way?
You should be able to define the style at the lowest level in the hierarchy where it becomes relevant and set the
TargetTypeof the style without a key.This will force the style to apply to the defined type down the hierarchy relative to its definition.
In this instance the resource would live within the
ListBoxand thus get applied to your template.