<ResourceDictionary>
<Style x:Key="Frame0" TargetType="Shape">
<Setter Property="Stroke" Value="Transparent" />
<Setter Property="StrokeThickness" Value="0" />
</Style>
</ResourceDictionary>
<Canvas x:Name="canvas" Height="346" Width="643">
<Rectangle Style="{StaticResource Frame0}" Stroke="Red" StrokeThickness="2" Height="77" Canvas.Left="26" Canvas.Top="13" Width="119" />
</Canvas>
I want anyone who uses my resource dictionary to always obey my rules. My style should be in the first priority. How to achieve that? Currently, Stroke=”Red” and StrokeThickness=”2″ overwrite my rules.
There’s no way to have the style value override the local value, as far as I know. Looking at the order of precedence, you’ll see that the local value is 3rd on the list, preceded only by coerced values, and values from active animations.
If you really need to force the value globally, then you could consider making a derived control that sets coerced values in the appropriate dependency properties.