WPF 写一个样式有水平居中垂直居中字体16文本框和标签控件都可以引用
<Style x:Key="CenteredTextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="FontSize" Value="16"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="CenteredLabelStyle" TargetType="{x:Type Label}">
<Setter Property="FontSize" Value="16"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
使用方式:
<TextBox Style="{StaticResource CenteredTextBoxStyle}"/>
<Label Style="{StaticResource CenteredLabelStyle}"/>
``
原文地址: https://www.cveoy.top/t/topic/cv11 著作权归作者所有。请勿转载和采集!