在我的 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>
我怎样才能做到这一点?