WPF 使Button字体自适应屏幕大小
使用Viewbox可以拉伸和缩放单个子元素以填满可用空间。
把viewbox直接放在默认格式的button外面
<Viewbox>
<Button>left</Button>
</Viewbox>
<ControlTemplate x:Key="radiusBtnTemplate" TargetType="Button">
<Border CornerRadius="48" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
<ControlTemplate x:Key="radiusBtnTemplate" TargetType="Button">
<Border CornerRadius="48" Name="PART_Background" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Viewbox>
<TextBlock Margin="10">
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</TextBlock>
</Viewbox>
</Border>
</ControlTemplate>
禁止转载,