Vista风格窗口关闭按钮在XP中

时间:2009-08-27 06:17:54

标签: wpf button styles

如何创建一个看起来像Vista关闭按钮的自定义按钮?任何人都可以有模板吗?

1 个答案:

答案 0 :(得分:4)

此模板将有助于制作Vista风格的窗口关闭按钮

    <Button>
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <Rectangle Width='60' Height='40' x:Name='MyRectangle'>
                <Rectangle.Fill>
                    <LinearGradientBrush x:Key="RedButtonBackground" StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Offset="0" Color="#F89C8C" />
                        <GradientStop Offset="0.45" Color="#D47F75" />
                        <GradientStop Offset="0.45" Color="#C04C3C" />
                        <GradientStop Offset="1" Color="#C98172" />
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName='MyRectangle' Property="Fill" >
                        <Setter.Value>
                            <LinearGradientBrush x:Key="RedButtonMouseOverBackground" StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Offset="0" Color="#F89C8C" />
                                <GradientStop Offset="0.45" Color="#E36A53" />
                                <GradientStop Offset="0.45" Color="#C72B0E" />
                                <GradientStop Offset="0.75" Color="#D44310" />
                                <GradientStop Offset="1" Color="#F5E478" />
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
</Button>