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 내부에 레이블을 사용하면 잘 작동합니다.