我有以下设想:
<UserControl.Resources>
<Style x:Key="NormalFontStyle">
<Setter Property="Control.FontFamily" Value="{Binding MyFont}"></Setter>
</Style>
<Style x:Key="BigFontStyle">
<Setter Property="Control.FontFamily" Value="{Binding MyFont}"></Setter>
<Setter Property="Control.FontSize" Value="{Binding MyBigFontSize}"></Setter>
</Style>
</UserControl.Resources>
<Grid Style="{StaticResource NormalFontStyle}">
<!-- Grid Contents -->
</Grid>
Grid的数据背景是含有MyFont和MyBigFontSize财产的《观点》。 上述法规是适当的,电网内的每一文本都适用“NormalFontStyle”。
Now the tricky part: I want to apply the "BigFontStyle" to a control inside the grid that may or may not have the same DataContext, which means that i cannot use this approach. Maybe binding the Values of the setters to static properties is the only way to go, (i just found this workaround for 3.5, which is my case here) but any light on this is welcome.