我有一组绑定到视图模型的样式。这适用于背景和前景。我现在想绑定字体大小。我可以让绑定工作,但是当我更改值并为该属性调用 PropertyChanged 时,它不会获得新值。有任何想法吗?
示例.xaml
<Style x:Key="ApplicationNameStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource NavigationForegroundColorBrush}"/>
<Setter Property="FontSize" Value="{Binding FontSize12, Source={StaticResource Sampe}}"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="0,2,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="10" Opacity="0.25" ShadowDepth="0"/>
</Setter.Value>
</Setter>
</Style>
示例视图模型.cs
public Double FontSize12
{
get
{
return _fontSize12;
}
set
{
_fontSize12 = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("FontSize12"));
}
}