Declare same style for TextBlock
同じように in Application resources
. 。これにより、アプリケーションのすべてのテキストブロックに適用されます。装飾者であろうとウィンドウの一部であろうと、アプリケーションのすべてのテキストブロックに適用されます。
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily"
Value="Tahoma" />
<Setter Property="FontSize"
Value="8pt"></Setter>
<Setter Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
</Style>
アップデート
リソースを複製したくない場合は、手に入れることができる最善です Label
それ以外の TextBlock
. 。そうすれば、スタイルを適用できます Control
スタイルを導き出すことができます Window
と Label
それから。
しかし、これは機能しません TextBlock
派生していないので Control
.
<Style TargetType="Control" x:Key="BaseStyle">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FontSize" Value="8pt"></Setter>
<Setter Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
</Style>
<Style TargetType="{x:Type Window}"
BasedOn="{StaticResource BaseStyle}"/>
<Style TargetType="{x:Type Label}"
BasedOn="{StaticResource BaseStyle}"/>
次に、TextBlockの代わりにAdornerdecorator内のラベルを使用する場合、正常に動作します。