1、WPF重新学习之路—按钮模版
<Button Width="100" Height="50" Content="点击" Foreground="Red" Click="Button_Click"> <Button.Template> <ControlTemplate TargetType="Button"> <Border Background="{TemplateBinding Background}" CornerRadius="20"> <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"></ContentPresenter> </Border> </ControlTemplate> </Button.Template>
ContentPresenter 是内容呈现器
1、先用Button.Template
2、再用ControlTemplate 里面写一个TargetType
3、在内容区域里要显示当前按钮的文本的话,使用 ConentPresenter