前台样式:
<Style x:Key="TxMagic" TargetType="TextBox">
<Setter Property="Background" Value="#FFFE0001"/>
<Setter Property="Foreground" Value="#FF1E0FA6"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="FontSize" Value="18px"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Height" Value="54"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
后台代码:
TextBox TxMagic = new TextBox();
TxMagic.Style = Resources["TxMagic"] as Style;
格式:
控件名.style = Resources["前台样式名"] as Style;