I want to use the same style for all Images and AutoGreyableImages (my custom control that inherits from Image). I have the following style declared application-wide:
<Style TargetType='{x:Type Image}' x:Key='ImageType'> <Setter Property='Stretch' Value='Uniform' /> <Setter Property='Height' Value='16' /> <Setter Property='Width' Value='16' /> <Setter Property='SnapsToDevicePixels' Value='True' /> </Style>
But the AutoGreyableImages don’t accept the style. This doesn’t work either:
<Style TargetType='{x:Type my:AutoGreyableImage}' BasedOn='{DynamicResource ImageType}' />
What is the correct way to do this?
You have to use a StaticResource reference in the dependent style.
Try this: