WPF Button

WPF Button 控件

一、WPF Button 添加图片

<Button>
    <Button.Content>
        <Image Stretch="Fill" Source="pack://application:,,,/程序集;component/images/demo.png"/>
    </Button.Content>
</Button>

 

二、删除默认的鼠标悬停效果

<Window.Resources>
    <Style x:Key="Button NoneStyle" TargetType="Button">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border Name="border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" Value="0.8" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

 

参考:

https://www.cnblogs.com/sshoub/archive/2012/08/22/2650942.html

https://www.cnblogs.com/sntetwt/p/7412627.html

 

WPF设置控件获取键盘焦点时的样式FocusVisualStyle

参考:https://www.cnblogs.com/tommy-huang/p/7447474.html

WPF中C#代码触发鼠标点击事件

参考:https://www.cnblogs.com/tommy-huang/p/4995625.html

 

WPF自定义Button样式(按钮长度随Content长度自适应)

参考:https://www.cnblogs.com/tommy-huang/p/5091602.html

 

wpf button style

参考:https://blog.csdn.net/zxlstudio/article/details/9428951

https://blog.csdn.net/qq_43024228/article/details/104886221

posted @ 2021-05-28 15:32  microsoft-zhcn  阅读(446)  评论(0编辑  收藏  举报