码迷,mamicode.com
首页 > Windows程序 > 详细

WPF圆角按钮例程

时间:2018-06-09 23:12:54      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:dir   XA   ado   smo   暂停   bsp   -name   code   例程   

<Window x:Class="WpfApp3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp3"
        mc:Ignorable="d"
        Title="我的例程" Height="450" Width="800" Background="Black">
    <Window.Resources>

        <Style TargetType="Button" >
            <Setter Property="Template">
                
                <Setter.Value>
                    <ControlTemplate TargetType="Button" >
                        <Border x:Name="border" Background="SkyBlue" 
                                CornerRadius="10" Height="30" BorderBrush="Black" BorderThickness="0" SnapsToDevicePixels="True">
                            <Border.Effect>
                                <DropShadowEffect Color="Black" Direction="0" ShadowDepth="1" Opacity="1" />
                            </Border.Effect>
                        <TextBlock Text="{TemplateBinding Content}" 
                                  VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="16" FontFamily="黑体">
                                <TextBlock.Effect>
                                    <DropShadowEffect Color="Black" Direction="0" ShadowDepth="1" Opacity="1" />
                                </TextBlock.Effect>
                            </TextBlock>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="LightBlue" TargetName="border"></Setter>
                            </Trigger> 
                            <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" Value="SkyBlue" TargetName="border"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
           
    </Style>
    </Window.Resources>
    <Grid Background="Brown" >
        <Button Content="暂停" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="445,344,0,0"></Button>
        <Button Content="添加" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"  Margin="100,344,0,0"></Button>
        <Button Content="播放" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="219,344,0,0"></Button>
        <Button Content="开始" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="327,344,0,0" ></Button>
    </Grid>
</Window>

 

WPF圆角按钮例程

标签:dir   XA   ado   smo   暂停   bsp   -name   code   例程   

原文地址:https://www.cnblogs.com/snow-zhang/p/9161574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!