Global implicit syle on the type Control in WPF
This style should apply on every control, but it has no effect, WHY?
<Style TargetType="{x:Type Control}">
<Setter Property="Margin" Value="1" /> 开发者_开发百科
</Style>
Your statement is incorrect. Implicit Styles are only applied to the specified type, not to types that derive from it.
For example, assume you have a custom button like:
public class MyButton : Button {
// ...
}
And an implicit Style like so:
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="1" />
</Style>
In the following XMAL, the Style above would not affect MyButton:
<Grid>
<Button />
<local:MyButton />
</Grid>
精彩评论