先将样式定义在App.xaml中 <Application.Resources> <Style x:Key="MsgTextBlock" TargetType="TextBlock"> <Setter Property="Height" Value="auto"/> <Setter Property="Width" Value="auto"/> <Setter Property="FontSize" Value="15"/> <Setter Property="Foreground" Value="Blue"/> <Setter Property="LineHeight" Value="3"/> </Style> </Application.Resources> 在后台调用: txtContent.Style = App.Current.Resources["MsgTextBlock"] as Style; 或: txtContent.Style = Application.Current.Resources["MsgTextBlock"] as Style; |
|
来自: 昵称10504424 > 《SilverLight》