私の WPF ListBox には、ListBoxItem の ControlTemplate を使用したスタイルがあります。その ControlTemplate 内に、ラベルが定義されています。いくつかの詳細に基づいて、ラベルのフォント サイズを変更する必要があります。コード ビハインドから、フォントがどうあるべきかを判断し、それを設定する必要があります。
ControlTemplate を使用した私のスタイルは次のとおりです (無関係なコントロールをいくつか削除しました)。
<Style x:Key="RecordTabList" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="{DynamicResource RecordIndexTabBackcolor}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Label
x:Name="myLabel" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" Margin="3,-2,0,-2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="{DynamicResource RecordIndexTabForeground}"
FontSize="10" Height="Auto" BorderThickness="3,0,0,0"
Content="{Binding Path=Name}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
これどうやってするの?