打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
button 鼠标移上下、不可用 变化图片

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!--   定义按钮样式-->
    <Style TargetType="Button">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid  x:Name="buttonbackground">
                        <Grid.Background>
                            <ImageBrush ImageSource="/WpfApplication1;component/image/button.png"></ImageBrush>
                        </Grid.Background>
                        <ContentPresenter Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="buttonbackground" Property= "Background">
                                <Setter.Value>
                                    <ImageBrush ImageSource="/WpfApplication1;component/image/button2.png"></ImageBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>

                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="buttonbackground" Property= "Background">
                                <Setter.Value>
                                    <ImageBrush ImageSource="/WpfApplication1;component/image/button3.png"></ImageBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="buttonbackground" Property= "Background">
                                <Setter.Value>
                                    <ImageBrush ImageSource="/WpfApplication1;component/image/button4.png"></ImageBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

  
</ResourceDictionary>

 


 
 
 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
WPF 倒三角按钮
Sharpui界面系统(纯C++)
WPF自定义按钮显示效果
WPF XAML 为项目设置全局样式
WPF自定义控件与样式(7)
继续聊WPF——自定义CheckBox控件外观
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服