我在WPF(c#)中编程。我试图改变风格的设定者的价值。更改设置值风格
我的风格是:
<Style TargetType="Control" x:Key="st">
<Setter Property="FontFamily" Value="Tahoma"/>
<Setter Property="FontSize" Value="14"/>
</Style>
我用它在一个按钮:
<Button x:Name="btnCancel" Style="{StaticResource st}" Content="انصراف" Canvas.Left="30" Canvas.Top="18" Width="139" Height="53" FontFamily="2 badr" FlowDirection="LeftToRight" Click="btnCancel_Click_1" />
,什么我尝试做的是这样的代码:
Style style = new Style();
style = (Style) Resources["st"];
Setter setter =(Setter) style.Setters[1];
setter.Value = 30;
设置字体后大小为30
我收到此错误?
一个“SetterCollectionBase”后在使用中(密封),它不能被修改
我怎样才能解决这个问题?
您使用的是风格的地方?显示更多代码。如果因为我只是使用你所拥有的,这是行得通的。 –
感谢您的关注。我更新它。 –