【发布时间】:2014-04-02 15:11:33
【问题描述】:
我在 xaml 中创建样式,但在后面的代码中我收到一个 NULL 值,我应该如何执行此代码?很抱歉这个问题我是新的,我想学习。
这是 xaml 代码:
<Style x:Key="TextBoxProperties" x:Name="TextBoxProperties" TargetType="TextBlock">
<Setter x:Name="textFontSize" Property="FontSize" Value="24"></Setter>
<Setter x:Name="textTypography" Property="FontFamily" Value="Resources/Fonts/Bryant-BoldAlt_Italic__Santillana.ttf#Bryant"></Setter>
</Style>
这是后面的代码:
private void btnIncreaseFont_Click(object sender, RoutedEventArgs e)
{
if (currentFontSize < MAX_FONTSIZE)
{
if (btnDecreaseFont.IsEnabled == false)
btnDecreaseFont.IsEnabled = true;
currentFontSize += 2;
TextBoxProperties.Setters.Add(textFontSize);
TextBoxProperties.Setters.Add(textTypography);
UpdateCurrentPage();
}
else
btnIncreaseFont.IsEnabled = false;
}
【问题讨论】:
-
你在哪里声明 currentFontSize 和 textFontSize?
-
不,我不只是从 xaml 中调用它们。